From: "Dr.Ruud" <[EMAIL PROTECTED]>
> Ovid schreef:
>
> > my $text = do { local $/; <$fh> };
>
> There is a problem with this idiom: it uses about twice the memory of
> this variant:
>
> my $text ; { local $/ ; $text = <$fh> }
>
> So if your files can be big (related to the amount of memory
> available), use the latter.
How do you know? it doesn't seem to be the case. I tried to load a
2MB file both ways and the memory consumption seemed to be the same
(plus or minus a few KB).
I tried then to load a 72MB file and the memory consuption was
77,532KB with the do{} and 77,452KB without. Not sure why the
difference, but it's definitely not twice more.
Unless of course I overlooked something.
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>