sub print_power_of_2 { my $x = shift; my $power_of_2 = sub { return $x ** 2; }; my $result = $power_of_2->(); print "$x^2 = $result\n"; }