http://www.perlmonks.org?node_id=1053790


in reply to Array of operators ...

Try something along these lines-

... my $statement = "4 $op 5"; print join(" = ", $statement, eval $statement), $/; ... __END__ 4 + 5 = 9 4 - 5 = -1 4 * 5 = 20 4 / 5 = 0.8

eval can be dangerous since it executes any code so be careful with it.