in reply to Re^2: Perl::Critic says don't modify $_ in list functions and other things
in thread Perl::Critic says don't modify $_ in list functions and other things
Using local $_ can fail if $_ is currently aliased to something read-only. The "Localization of special variables" and "Localization of globs" sections in perlsub explained this and recommended using local *_ instead in the affected versions. You can avoid problems with also localizing @_ by unpacking your arguments into lexicals before localizing *_.
Beginning with perl 5.14, local $_ is a special case that also strips any magic associated with $_, while preserving the other slots in *_. Since Lady_Aleena mentions that her Web host is using a perl older than 5.14, this is a concern for our questioner.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Perl::Critic says don't modify $_ in list functions and other things
by haukex (Archbishop) on Jul 11, 2020 at 06:18 UTC | |
by jcb (Parson) on Jul 12, 2020 at 03:20 UTC | |
by haukex (Archbishop) on Jul 12, 2020 at 05:58 UTC |