Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: passing a variable value to Unix command

by ikegami (Patriarch)
on Oct 20, 2010 at 00:15 UTC ( [id://866204]=note: print w/replies, xml ) Need Help??


in reply to passing a variable value to Unix command

I had a hard time generating that error.

$ find . -name "doesn't exist" -print $ find . -name "" -print $ find . -name -print $ find . -name find: missing argument to `-name'

There's no way the command you're executing could generate that error with my find. Maybe if $k contained a newline and you hadn't used quotes.

Anyway, if you want to avoid unintentional interpolation, use IPC::System::Simple's capturex.

my $output = capturex(find => ( -name => "$k*", -print ));

By the way, "\*" is the same as "*".

Log In?
Username:
Password:

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

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

    No recent polls found