Just to demonstrate the effect of dynamic scoping that AnomalousMonk already described:
sub foo { local *bar = sub { print "other bar\n"; }; print "foo calling quz\n"; quz(); } sub bar { print "bar\n"; } sub quz { print "quz calling bar\n"; bar(); } foo(); quz(); __END__ Subroutine main::bar redefined at - line 4. foo calling quz quz calling bar other bar quz calling bar bar
Despite the warning about the subroutine being redefined, this can cause some spooky action-at-a-distance effects: How do you know which bar() you'll be calling (as demonstrated by sub quz)?
In reply to Re: Memory efficiency, anonymous vs named's vs local subroutines
by Anonymous Monk
in thread Memory efficiency, anonymous vs named's vs local subroutines
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |