Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Executing text

by paulacocacola (Initiate)
on Nov 26, 2003 at 14:31 UTC ( [id://310258]=perlquestion: print w/replies, xml ) Need Help??

paulacocacola has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I've never used Perl but I'm going to do a project where i will need to read a text and execute it. Meaning the program should be able to receive (for example) the text :Print 'Hello World'; and do execute(Print 'Hello World'). After that, I'll need to receive a function (in plain text), and be able to execute it (may have parameters). Does anyone know how can i start to do this? Where should i begin? thanks

Replies are listed 'Best First'.
Re: Executing text
by duff (Parson) on Nov 26, 2003 at 14:37 UTC
Re: Executing text
by BazB (Priest) on Nov 26, 2003 at 15:06 UTC

    As duff suggests, you should read perlsec.
    Just to stress the point: accepting input from an untrusted source - especially when that input will be eval'ed by perl - can be a serious security hole.

    Imagine if the input was `rm -rf /`...


    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

      Sounds like you want to learn the eval command in Perl, and might want to take a look at Text::Template.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2025-03-27 04:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (69 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.