Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Read System output Into a variable Name?

by fglock (Vicar)
on Feb 01, 2005 at 19:26 UTC ( [id://427021]=note: print w/replies, xml ) Need Help??


in reply to Read System output Into a variable Name?

use backticks:

$var = `some system call`;

Replies are listed 'Best First'.
Re^2: Read System output Into a variable Name?
by dragonchild (Archbishop) on Feb 01, 2005 at 19:49 UTC
    Backticks are less efficient than using open() and |. For one thing, backticks have to read the whole result into memory at once. For another, having the second process running while you're dealing with the input allows the scheduler to be more efficient.

    Additionally, backticks interpolate, which can cause issues with set-id scripts. Pipes get around this.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      For the latter issue, regarding interpolation of the command string itself, see qx// with single-quotes.
      $output = qx' command @which $should not be interpolated ';

      --
      [ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-18 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found