On 22 Oct 2004 06:41:10 -0700, Randal L. Schwartz <[EMAIL PROTECTED]> wrote: > >>>>> "Bryan" == Bryan Harris <[EMAIL PROTECTED]> writes: > > Bryan> I'm using the: > > Bryan> @files = <*.in>; > > Bryan> ... notation with Perl 5.0. If I have too many files, @files ends up with > Bryan> nothing. Is there a way to read in all 20k names? > > Upgrade to Perl 5.6 or later. The globbing no longer calls /bin/csh, > and thus avoids the shell's command-line-length limitations. > > Or, learn to use readdir(), which is clunkier.
Ouch! I *always* used readdir() in preference to the bizarre <*> notation... But then I'm a C programmer at heart.. opendir( DIR,"$base_dir" ) ; %files = map { "$base_dir/$_" => [ stat( "$base_dir/$_" ) ] } grep { /\.in$/ } readdir( DIR ); closedir ( DIR ); voila - a HASH of filenames where each filename has its inode info attached for optimising later when you sort by file size, or access date.. I prefer the ability to 'grep' the directory listing rather than rely on globbing which isnt always precise enough.. This is especially useful when you are grepping on say, whether it is a file or directory, whether the modified time is earlier than today etc.. As a consultant, I have had to convert what Bryan does with <*> to what I consider 'proper' readdir style syntax to overcome filename expansion limits on directories with lots of files.. (ie, when 20000 files in a directory would be considered a slow day). Note that these are transient files in an OLTP environment and on some days they arrive so fast I've found '<*>' sometimes doesn't return.... > > -- > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 > <[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/> > Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. > See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>