Well, I said "basically" never. Like all blanket statements, there are exceptions. Perhaps I should have said: Use my by default, use local when you understand why you can't use my in a specific situation. You can create 'stack-like' aggregates with local as you demonstrate, but you need a very good reason.
# some good reasons: # if you modify a side-effect global like $/, # do it in the smallest scope possible: my $slurped = do { local $/; <$some_Fhand> }; # override an element of a global aggregate in a # limited scope: { local $SIG{"ALRM"} = \&some_handler; alarm $timeout; some_action(); }
Of course, I agree that understanding the difference is much better than applying a blanket maxim. (Which is why I pointed to an article that does just that.)
In reply to Re^3: local variable syntax
by fishbot_v2
in thread local variable syntax
by yburge
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |