RosettaCodeData/Task/Runtime-evaluation-In-an-environment/Perl/runtime-evaluation-in-an-environment.pl
2023-07-01 13:44:08 -04:00

8 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".