Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Memory Leak when slurping files in a loop

by Anonymous Monk
on Dec 07, 2010 at 04:24 UTC ( [id://875734]=note: print w/replies, xml ) Need Help??


in reply to Memory Leak when slurping files in a loop

It would help if it compiled under strictures.

Maybe something simpler would work.

#!perl use strict; use warnings; use autodie; # chdir and open die on error use File::DosGlob 'glob'; # DOS-style wildcards use File::Slurp 'slurp'; my $dir = 'c:/mydir/'; my $maxsize = 0; chdir $dir; for my $file (glob('*')) { # check size my $size = -s $file; $maxsize = $size if $size > $maxsize; print "$_: $size\n"; # get contents my @lines = slurp $_; # one string per line #my $lines = slurp $_; # only one string # manipulate contents #... } # report print "\n\nmax file size: $maxsize\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://875734]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (1)
As of 2024-04-16 15:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found