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


Reply via email to