Dr.Ruud wrote: > "Dr.Ruud" schreef: >>Mathew Snyder: > >>>foreach my $file (sort(readdir DH)){ >>> push @filenames, $file; >>>} >>You sort too early. > > Ignore that. Just use John's alternative: > > my @filenames = sort readdir DH; > > or make that > > my @filenames = sort grep -f, readdir DH;
Please read the readdir entry in perlfunc, and then read it again very carefully. You are testing a file from a different direcory so the -f test will probably always fail! If you just want the file names in @filenames: my @filenames = sort grep -f "$processDir/$_", readdir DH; If you want the complete path names in @filenames: my @filenames = sort grep -f, map "$processDir/$_", readdir DH; > Globs are sorted nowadays, Usually: perldoc File::Glob [snip] "GLOB_NOSORT" By default, the pathnames are sorted in ascending ASCII order; this flag prevents that sorting (speeding up bsd_glob()). > I don't know whether readdir is too. No. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>