use 5.014; use warnings; our ($x, $y) = (2, 2); sub sum_of_squares { my ($a, $b) = @_; ($a * $a) + ($b * $b); } sub sum_of_squares_for_x_and_y { sum_of_squares $x, $y } say sum_of_squares_for_x_and_y; # => 8 { local ($x, $y) = (10, 5); no warnings 'redefine'; local *sum_of_squares = sub { my ($a, $b) = @_; $a / $b; }; say sum_of_squares_for_x_and_y; # => 2 } say sum_of_squares_for_x_and_y; # => 8
http://news.ycombinator.com/item?id=3446384 | http://news.ycombinator.com/item?id=3423631
http://news.ycombinator.com/item?id=3446384 | http://news.ycombinator.com/item?id=3423631