Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Executing perl code

by SuicideJunkie (Vicar)
on Feb 13, 2013 at 18:53 UTC ( #1018600=note: print w/ replies, xml ) Need Help??


in reply to Executing perl code

Just make sure nobody types "format c:" into that configuration script!

A much safer way to go about it is to read the config file and look up the provided command in a hash to make sure it is legit.

my ($cmd, @params) = split ',', <$inputFileHandle>; if (exists $hashOfAllowedCommands{$cmd}) { $worksheet->$hashOfAllowedCommands{$cmd}->(@params) }else{ print "Invalid command ignored in config file at line $.\n"; }

If you still want to play with the dynamite then take a look into eval


Comment on Re: Executing perl code
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2015-07-29 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (265 votes), past polls