T
Tay Ray Chuan
Hi, I tried using eval like this:
print "Enter something to evaluate:\n";
while (defined($s = <>)) {
$result = eval $s;
if ($@) {
print "Invalid string:\n $s";
} else {
print "$result\n";
}
}
this can evaluate anything. but when I type this:
"$a=5;$b=5;$c=$a+$b;print $c;", it prints "101".
Why is there an extra "1"?
print "Enter something to evaluate:\n";
while (defined($s = <>)) {
$result = eval $s;
if ($@) {
print "Invalid string:\n $s";
} else {
print "$result\n";
}
}
this can evaluate anything. but when I type this:
"$a=5;$b=5;$c=$a+$b;print $c;", it prints "101".
Why is there an extra "1"?