I should use "eval EXPR", not "eval BLOCK". Thanks!

-----Original Message-----
From: Zhao, Bingfeng [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 20, 2008 11:13
To: Perl Beginners
Subject: How to turn a user perl script in string format into actual
perl commands that eval accepts in my script?

Hello,
I encounter following requirements:
1. accept customized perl sentences;
2. provide variables exchange between customized perl sentences and my
routine.

Here is a sample:

[code]
use strict;
use warnings;

# we use $_ to pass value in and out
$_ = qw/foo/;
my $cmds = "print $_; $_ = qw/bar/";
eval {$cmds};
my $result = $_;
print $result;
[/code]

But I got a error: Useless use of private variable in void context at
ss.pl line 7. So how can I do? Thanks in advance.


Best regards, 
Bingfeng 




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to