Hi Stuart,

On Wednesday 01 September 2010 14:55:21 Kryten wrote:
> Hi,
> 
> I'm very much a beginner.
> 
> Could anyone point me in the right direction on how to accomplish the
> following, please?
> 
> I have a fairly long log file call it file A, it has around 20,000
> lines of three element space separated variables.
> 
> File A looks like:-
> 
> 55223 jimmy smith
> 55224 davy crocket
> 55227 walter mitty
> 63256 mickey mouse
> ..
> 
> I also have a .txt file with around 600 of the numbers found in file
> A. Cal that File B.
> 
> File B looks like:-
> 
> 63256
> 55223
> ..
> 
> I need to (quickly as possible) remove all the lines from File A,
> whose numbers can be found in File B.
> 
> Now, I have this working just fine in Windows Powershell, but it
> really slow, as I am foreaching file b into a where-object filter, it
> works but takes minutes to run. Based on my limited exposure to perl,
> I'm pretty certain that TMTOWTDI !!

Use a hash:

http://perl-begin.org/topics/hashes/

Populate the keys of the hash with the number of file B, read file A line by 
line and check if they exist in the hash to filter them out, while writing a 
new temporary file.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Parody on "The Fountainhead" - http://shlom.in/towtf

God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to