in reply to Re^2: Producing 2 lists from a grep call
in thread Producing 2 lists from a grep call

this code does not work -- !-d  !=  -f!

to implement this code properly, you must test for both -d, and -f, and ignore the rest. add next unless -d $_ or -f _; before the push statement and you'll have what you're looking for.

for (readdir DIR) { next if $_ eq '.' or $_ eq '..'; next unless -d $base . '/' . $_ or -f _; push @{ -d $base . '/' . $_ ? \@dirs : \@files }, $_; }
Update: changes as per Screamer

Update 2: for more info on filetests, see -X under perlfunc

~Particle *accelerates*

Replies are listed 'Best First'.
Re^4: Producing 2 lists from a grep call
by Aristotle (Chancellor) on Jun 17, 2002 at 12:35 UTC
    next unless -d $_ or -f _; Careful, it's "$base/$_". Excellent point though.

    Makeshifts last the longest.