RosettaCodeData/Task/Runtime-evaluation-In-an-en.../Perl/runtime-evaluation-in-an-en...

9 lines
193 B
Perl

sub eval_with_x
{my $code = shift;
my $x = shift;
my $first = eval $code;
$x = shift;
return eval($code) - $first;}
print eval_with_x('3 * $x', 5, 10), "\n"; # Prints "15".