Thanks! Eval was it. I knew there was something but I never use eval. Thanks for the
kick in the pants!
What I'm going to end up using is this :
eval $code;if($@) { $error = "$error $@"; }
Dan
-----Original Message-----
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 17, 2002 1:26 PM
To: Dan Muey
Cc: [EMAIL PROTECTED]
Subject: Re: using script vars and routines when doing backtick execution of perl -e
from within the script
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]