in reply to
extract an operator from a string
You could use the eval function:
my $calc="1+2"; print eval ($calc) ."\n";
[download]
Prints 3. (eval will execute any perl code passed to it, so you should read up on taint checking and the -T switch).
Comment on
Re: extract an operator from a string
Download
Code
In Section
Seekers of Perl Wisdom