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

Reaped: Re: Executing a string as a Perl command

by NodeReaper (Curate)
on May 10, 2011 at 09:24 UTC ( #903934=note: print w/ replies, xml ) Need Help??


in reply to Executing a string as a Perl command

This node was taken out by the NodeReaper on May 17, 2011 at 08:15 UTC
Reason: [ww]: reap. dup of 903932

You may view the original node and the consideration vote tally.


Comment on Reaped: Re: Executing a string as a Perl command
Re^2: Executing a string as a Perl command
by Jenda (Abbot) on May 10, 2011 at 13:57 UTC

    Drop the double quotes! They are not necessary (in this case) and just slow the code down. In some cases blindly enclosing variables in quotes would lead to strange looking bugs. This is Perl, not a shell script.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

      The "slow the code down" is so small as to be non-existent.

      xoxo,
      Andy

        I agree. It's a question of readability. It requires extra thought to process the unexpected and useless quotes.
        I thought using eval in that way, on a scalar to execute a command is a NO-NO for security and not best practice!

        cant you just use the qx or system call?

        Depends. If the variable contains a short string, then the slow down will be negligible. If it contains a number and the subroutine needs to do some more computations, then you've just forced perl to convert the number to a string and back. If nothing more, it's wasteful.

        Then there is yet another case. What if the variable contains a huge string? You've just made yet another copy ...

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-12-22 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (112 votes), past polls