Note that named subroutine declarations are always evaluated before any code that call them, so the location is "irrelevant", which also means that there aren't any situations where you "must keep the location" of the declaration.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"; }
In reply to Re: nested routines, anonymous routines and location dependency
by Joost
in thread nested routines, anonymous routines and location dependency
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |