I know this is off-topic, but my search engine left me nowhere else to go.
Can you please forgive a newbie and answer a Perl question?
The question is this: I have an expression, for instance as follows, in a
scalar (string):
$eval = "80-5";
What I want to do is to evaluate this and get the value of it.
What I have tried is
$expr = "\$result = (" . $expr . ")"; # parentheses are the result of
desperation
eval { $expr; }; warn $@ if $@; # I'm trying to get the value of
80-5... that is, 75
print $result; # this variable's value is
always 0
What is the correct incantation for this? By the way, I don't see any
warnings of any
kind. I used the "warn $@ if $@;" simply because it was in the example in
the Camel book; I thought it might help enlighten me somehow..
Regards, Melora