in reply to Re: What is faster?
in thread What is faster?
The <OUTPUT> construct immediately sucks the whole file into memory. To get the full space savings that you describe (not using variables will get you some...), you need to do something like this:
With the emphasis on creative laziness that they keep on talking about for Perl 6, it is possible that Perl 6 will automatically save memory for you with your construct. It is definite that Ruby does. But with Perl 5, you need to write things out longhand.open(OUTPUT, "$script |") or die "Cannot run '$script': $!"; my @output; while (<OUTPUT>) { push @output, $_ if /EXPRESSION/; }
UPDATE Zaxo pointed out that I didn't close the diamond properly. Fixed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: What is faster?
by BrowserUk (Patriarch) on Jun 03, 2003 at 06:00 UTC |