in reply to Re: Help with a faster loop
in thread Help with a faster loop
The only global here is the DATA filehandle, but you should pass that along through the subroutine chain as a parameter.use strict; use Memoize; memoize ('read_files'); sub process_files { my $dir_path = shift; if (opendir(TEST, $dir_path)) { my @files = sort grep{$_ ne '.' and $_ ne '..'} readdir(TEST); #print "\n@files[0]\n"; read_files("$dir_path\\$_") foreach (@files); } else { die ("Could not Opendir $dir_path: $!\n"); }closedir TEST; } sub read_files { my $file_path = shift; if (-f $file_path) { print (DATA "$file_path\n") if ($file_path !~ /(\.lfa|\.zip|\. +txt|UASTG)$/); } else { die ("Could not open[$file_path], $!\n"); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Searching XML files
by Anonymous Monk on Mar 01, 2006 at 19:38 UTC |