Dan

I'm not a Unixite, but something like

    eval $ENV{$code_here};

will do the trick.

Rob



----- Original Message -----
From: "Dan Muey" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 17, 2002 10:24 PM
Subject: Executing a variable that contains perl code


> Anybody know of any modules or ways to execute a variable that contains
perl code as if it were part of the script?
>
> IE do : print `/usr/bin/perl -e '$code_here'`;
>
> Except be able to use variables/arrays/hashes/routines that are in the
script  with that line
>
> EG : print `/usr/bin/perl -e '$code_here'`;
> Works great if $code_here is just a print statement or uses it's own
vars/routines, etc
> But I need to be able to have some code like this :
>
> $joemama = "HI";
> sub joe { print "Mama"; }
>
> $code_here = 'print $joemama\;&joe\;'; # actually this var gets set with
perl code in a mysql database
>
> print `/usr/bin/perl -e '$code_here'`;
>
> output this :
> HIMama
>
> How can I get it to be able to use the script's vars and routines etc?
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to