go ahead... be a heretic | |
PerlMonks |
Re: Perl backticks and GREP?by jakobi (Pilgrim) |
on Oct 19, 2009 at 17:12 UTC ( [id://802037]=note: print w/replies, xml ) | Need Help?? |
See also my recent Re: *SAFE* use of string in system command for safe use of filenames. Use %ENV and the old standby of adding /dev/null to force grep to print filename**s**. That way names containing quotes and worse won't create a mess.
Above is as usual incomplete and a bold lie: the reporting with still suffer in case of an embedded but unfiltered \n being a part of the filename (UTF-8 probably also offers some more interesting whitespace to play with; names with terminal esc sequences are also fun in print, warn & die). But especially \n really warants IMAO a cronjob and a shoot-and-kill policy for both file and file creator upto and including layer 8. cu 1. of course, this (unnecessary) last minute addition of /dev/null belongs before the closing `-quote, just as your first parsing error indicated. Sorry & fixed above. 2. Oops: you need to move down the $ENV{file} (in your example below) into the first foreach loop. The $ENV{argument} similar after $argument has been assigned to, into the second loop, or better yet, trading efficiency to readability, both just before the grep. 3. ok, compare your version with the full working one here and do check the comments:
In Section
Seekers of Perl Wisdom
|
|