in reply to Don't Use Local
in thread nuances of my, and maybe local
And you still need local to give a temporary value to a package variable, especially a special variable. For example, this is perfectly sane code:
This works because the setting for $/ (a global variable) will be affected for only the duration of the block in which the local appears: just long enough to get the value.my $slurp_file = do { local $/; # slurp mode... <SOME_HANDLE>; };
So, it's not never use local, but rather, be sure you know when to use it (rarely) and when not to use it (mostly).
-- Randal L. Schwartz, Perl hacker
|
|---|