in reply to Perl file operations
While I don't have a directory with 60,000 files in it to test your code I would guess that <*.txt> is creating such a large list that it runs out of memory. Try using opendir and then readdir in a while loop to cut down on memory usage:
opendir my $DH, '.' or die "Cannot open the current directory: $!"; while ( my $file = readdir $DH ) { next if '.txt' ne substr $file, -4;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl file operations
by chromatic (Archbishop) on Feb 23, 2008 at 04:42 UTC | |
by SkullOne (Acolyte) on Feb 23, 2008 at 05:54 UTC | |
by zshzn (Hermit) on Feb 23, 2008 at 21:41 UTC |