> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 01 October 2001 15:16
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: eval problem
> 
> 
> 
> 
> Hi everybody,
> 
> I am facing a little problem with eval in perl.
> 
> say I do the following:
> 
>  $a = "print \"hi\""
> > eval($a)
> hi> $b = eval($a)
> hi> print $b
> 1>
> 
> The above piece of code, prints the output of eval statement 
> on the STDOUT, and
> I only get the return status of the EXPR in eval statement.
> But I have no way to capture this output in some variable.
> 
> Instead of this behaviour of eval, Can I get what I want 
> .i.e.. Can I capture
> the output in some variable.
> Like here I am printing "hi" on stdout. But I want this "hi" 
> to be stored in
> some variable also.
> 
> Please help,
> 
> TIA,
> -Mini.


Rather than use the eval command, use backticks like this

$A = `echo "Hello World"`;
print "Command has run, \$A is:";
print $A;

$A will contain the output of the command executed inside the backticks

HTH


                Rod the IFFO
 
                Mailto:[EMAIL PROTECTED]
                Tel: +44-1293-584145
                Mob: +44-7711-553080
                Fax: +44-1293-584994

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

Reply via email to