Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

•Re: Producing 2 lists from a grep call

by merlyn (Sage)
on Jun 16, 2002 at 19:52 UTC ( [id://174963]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-25 20:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found