Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Backtics and variables

by toolic (Bishop)
on Mar 16, 2010 at 14:22 UTC ( [id://828940]=note: print w/replies, xml ) Need Help??


in reply to Backtics and variables

When using backtics to execute a command will variables be substituted correctly if placed within?
Yes, backticks (qx) will interpolate variable values. As Corion said, refer to perlop.
$result = 'somecommand $filename';
Will the variable filename have it value substituted in or will it get interpreted literally as $filename?
You used single quotes (q) in your example, not backticks. So, your question does not seem to match your example code. Since single quotes do not interpolate, $result will contain the literal string $filename, which you can easily prove to yourself by using print to inspect its value, as Corion also pointed out. You probably want:
$result = `somecommand $filename`;
or:
$result = qx(somecommand $filename);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-03-28 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found