Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: How do I get both the return value and text? backticks vs. system()

by jffry (Hermit)
on Feb 14, 2006 at 23:34 UTC ( [id://530256]=note: print w/replies, xml ) Need Help??


in reply to How do I get both the return value and text? backticks vs. system()

If you especially don't want the shell interpreting shell metacharacters, then don't pass the command to the shell, use the 4+ argument form of open.
open(CMD, '-|', '/usr/bin/ls', '$4', '$PATH'); my $output = do { local $/; <CMD> }; close CMD; print "$output\n";
Here is the output, you'll see that the "$4" and "$PATH" were not interpreted as variables before being sent to ls.
ls: 0653-341 The file $4 does not exist. ls: 0653-341 The file $PATH does not exist.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-23 15:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found