eval may be what you want. Check out:

perldoc -f eval

Or you might have to pass a -M<module name> or a 'require' statement to your perl -e line, if I am understanding at all correctly.

http://danconia.org

Dan Muey wrote:
I have a need to get perl code from a database into a variabole and then execute it.
I can get it to work no problem if I'm just printing, or do my own vars and routines ( EG : $input contains $var = 1; and sub mon { print $var; } &mon; it wil print 1 )
But I can't use variables and subroutines that are in that script. ( EG : $var and sub do {..} below )
Does any one know a way to use the script's vars and routines if they are called form perl code found in the $input var below??
###################### script #####
#!/usr/bin/perl
$input = &get_perl_code_from_db;
$var = 1;
sub do { print "Monkey"; }
print `/usr/bin/perl -e '$input'`;
#################################
if $input just has : print "HI \n";
OUTPUT : HI
if $input has : print "Number $var \n";
OUTPUT : Number
if $input has &do;
OUTPUT : Undefined subroutine error
What I need to be able to do is use variable and subroutines that exist elsewhere in the script


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

Reply via email to