in reply to Re^2: Reliably simulating 5.10 say()
in thread Reliably simulating 5.10 say()
The best practice of not using globals is like "don't use goto" or "don't do drugs" - the rule exists because the majority of people abuse them. This is one of the cases where you know what you are doing and why - you're not defining a new global, instead you want to use $_ for its intended purpose. So don't worry :-)
The only minor caveat about $_ might be if someone were using the experimental lexical $_, introduced in Perl 5.10 and made experimental due to various problems in 5.18:
sub foo { print "<$_>\n" } for (qw/a b/) { foo; for my $_ (qw/x y/) { foo; } } __END__ Use of my $_ is experimental at - line 4. <a> <a> <a> <b> <b> <b>
But that's a case of "the user got what they were asking for", plus there's the warning about it being experimental.
P.S. Have you seen Perl6::Say and Say::Compat? And by the way, the former simply does this in its source: @_ = $_ unless @_;
|
|---|