in reply to Producing 2 lists from a grep call

Applying the KISS principle:
my @dirs; my @files; for (readdir DIR) { next if $_ eq "." or $_ eq ".."; if (-d "$base/$_") { push @dirs, $_; } else { push @files, $_; } }
Don't try to cooerce everything into a grep.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: •Re: Producing 2 lists from a grep call
by Anonymous Monk on Jun 17, 2002 at 12:02 UTC
    Run that code on /dev and it will get seriously wrong results.

    A file isn't just anything that is not a directory.