Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Shell Commands executed in perl script

by Moron (Curate)
on May 22, 2007 at 15:03 UTC ( [id://616785]=note: print w/replies, xml ) Need Help??


in reply to Shell Commands executed in perl script

And yet another reason not to shell is that grep (albeit a more flexible variant) is available in Perl anyway, e.g.:
print join ("\n", grep !(( -d $_ ) || /^file1$/ ), glob './logs/*' ) . + "\n";
n.b. your original code will exclude any file for which file1 is a substring found anywhere in the ls -l line for the file - that's a lot of potential holes ... /^files1$/ operating on what the glob returns closes them all, /file1/ would exclude also any file where file1 is any substring of the filename. That seems almost but not quite as unlikely to DWYM under rigorous testing.
__________________________________________________________________________________

^M Free your mind!

Log In?
Username:
Password:

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

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

    No recent polls found