Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Producing 2 lists from a grep call

by particle (Vicar)
on Jun 17, 2002 at 12:26 UTC ( [id://175056]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://175056]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found