Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^5: Executing a string as a Perl command

by Anonymous Monk
on May 16, 2011 at 11:01 UTC ( #905046=note: print w/replies, xml ) Need Help??


in reply to Re^4: Executing a string as a Perl command
in thread Executing a string as a Perl command

eval is the wrong answer since it can run arbitrary code

If the user gives you some form of # rm -rf * ~ / , a lot of your files get deleted

Replies are listed 'Best First'.
Re^6: Executing a string as a Perl command
by ctilmes (Vicar) on May 16, 2011 at 13:25 UTC
    The OP said nothing about a user supplying the string. We pointed out that there are security concerns if you don't trust the string.

    If you want to run arbitrary code supplied by a 100% trusted source at runtime, what would you use other than eval?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://905046]
help
Chatterbox?
[Discipulus]: LA something a little more perlish? @mts = map {qx!mp3info -p $_!} glob '/path/*.mp3 (hazarded code)
[Discipulus]: many monks want to be hired tonight, other haired and some aired
[Lady_Aleena]: Discipulus, do glob recurse?
[Lady_Aleena]: s/do/does/;
LanX wants to be fired
[Discipulus]: i fear no

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2017-04-23 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.