Re: Recursively filter an array

2010-09-03 Thread Dr.Ruud
On 2010-09-02 21:15, Chas. Owens wrote: my $string = do { open my $fh, "<", "filename" or die $!; local $/; <$fh>; }; To make it use less memory, write it like this: my $string; { open my $fh, "<", "filename" or die $!; local $/; $string = <$fh>; }; -- Ruud -- To unsubs

Re: Recursively filter an array

2010-09-02 Thread Uri Guttman
> "CO" == Chas Owens writes: CO> You may think there is more code in the while loop version, but really CO> it there is less. File::Slurp is a pure Perl module. That means that CO> whatever loop it is using to get the data must happen in Perl. Then CO> you copy that data to an arra

Re: Recursively filter an array

2010-09-02 Thread Chas. Owens
On Thu, Sep 2, 2010 at 13:08, Uri Guttman wrote: snip > for the excluded hash, it is simpler and probably much faster than line > by line. the latter way needs to run much more perl code which is slower > than a single slice. i won't benchmark it because it is also better > coding which is more im

Re: Recursively filter an array

2010-09-02 Thread Uri Guttman
> "CO" == Chas Owens writes: CO> On Thu, Sep 2, 2010 at 04:39, Uri Guttman wrote: CO> snip >> if you want speed, that is not the best way to read in the file >> lines. File::Slurp (on cpan) can do that for you and is cleaner as well: CO> snip CO> If there was one thing I could c

Re: Recursively filter an array

2010-09-02 Thread Chas. Owens
On Thu, Sep 2, 2010 at 04:39, Uri Guttman wrote: snip > if you want speed, that is not the best way to read in the file > lines. File::Slurp (on cpan) can do that for you and is cleaner as well: snip If there was one thing I could change about this list, it would be that to ban people from saying

Re: Recursively filter an array

2010-09-02 Thread Shlomi Fish
Hi Stuart, a few comments on your code. On Wednesday 01 September 2010 21:18:10 Kryten wrote: > Wow. Thank you Shlomi, Thank you Chas and Thank you Shawn. > > Hash sets seem to be the way to go here. Much quickness too! > > Here is what I have ( the least I can do is give you all a chance to >

Re: Recursively filter an array

2010-09-02 Thread Uri Guttman
> "K" == Kryten writes: K> Here is what I have ( the least I can do is give you all a chance to K> laugh K> at my code! ):- here comes the laughter! :) K> #!/usr/bin/perl K> use warnings ; put use strict in there too. you are declaring some vars, strict enforces that you declar

Re: Recursively filter an array

2010-09-02 Thread Kryten
Wow. Thank you Shlomi, Thank you Chas and Thank you Shawn. Hash sets seem to be the way to go here. Much quickness too! Here is what I have ( the least I can do is give you all a chance to laugh at my code! ):- #!/usr/bin/perl use warnings ; my $names_file = 'C:\names.log' ; my $exclude_list =

Re: Recursively filter an array

2010-09-01 Thread Shawn H Corey
On 10-09-01 07:55 AM, 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:-

Re: Recursively filter an array

2010-09-01 Thread Chas. Owens
On Wed, Sep 1, 2010 at 07:55, 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.

Re: Recursively filter an array

2010-09-01 Thread Shlomi Fish
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 spa