in reply to Recover a mathematical expression from a string.
How about storing it in a subroutine instead?
my $func = sub { my $x = shift; return 3 * ( $x**3 ) - 2 * $x + 4 }; my $to_x = $func->( $x ); my $to_y = $func->( $y );
eval is a big, dangerous stick to carry around.
|
|---|