See tickets #114020 and #75598 for why.
The changes to tests in cpan/Text-Tabs have been submitted upstream
at rt.cpan.org #81698.
sub check_data {
+ local $_;
binmode(DATA, ":utf8") || die "can't binmode DATA to utf8: $!";
- while ( my $_ = <DATA> ) {
+ while ( <DATA> ) {
my $bad = 0;
sub check_data {
binmode(DATA, ":utf8") || die "can't binmode DATA to utf8: $!";
- while ( my $_ = <DATA> ) {
+ local $_;
+ while ( <DATA> ) {
my $bad = 0;
-use warnings;
+use warnings; no warnings 'deprecated';
use strict;
use Test::More tests => 4;
PL_parser->in_my == KEY_state ? "state" : "my"), flags & SVf_UTF8);
}
}
+ else if (len == 2 && name[1] == '_' && !is_our)
+ /* diag_listed_as: Use of my $_ is deprecated */
+ Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
+ "Use of %s $_ is deprecated",
+ PL_parser->in_my == KEY_state
+ ? "state"
+ : "my");
/* allocate a spare slot and store the name in that slot */
it already went past any symlink you are presumably trying to look for.
The operation returned C<undef>. Use a filename instead.
+=item Use of my $_ is deprecated
+
+(D deprecated) Lexical $_ is deprecated because of
+its confusing side-effects. Consider using C<local $_>
+instead. See the explanation under L<perlvar/$_>.
+
=item Use of %s on a handle without * is deprecated
(D deprecated) You used C<tie>, C<tied> or C<untie> on a scalar but that scalar
however, because you can overload the numification and stringification
operators and then you presumably know what you are doing.
+=item Use of state $_ is deprecated
+
+(D deprecated) Lexical $_ is deprecated because of
+its confusing side-effects. Consider using C<local $_>
+instead. See the explanation under L<perlvar/$_>.
+
=item Use of tainted arguments in %s is deprecated
(W taint, deprecated) You have supplied C<system()> or C<exec()> with multiple
expects to be passed information via C<$_>, it may or may not work,
depending on how the function is written, there not being any easy way to
solve this. Just avoid lexical C<$_>, unless you are feeling particularly
-masochistic.
+masochistic. For this reason lexical C<$_> is deprecated and will produce
+a warning unless warnings have been disabled.
Mnemonic: underline is understood in certain operations.
like( $@, qr/Too many arguments for main::f at/ );
{
+ # We have not tested require/use/no yet, so we must avoid this:
+ # no warnings 'deprecated';
+ BEGIN { $SIG{__WARN__} = sub {} }
my $_ = "quarante-deux";
+ BEGIN { $SIG{__WARN__} = undef }
$foo = "FOO";
$bar = "BAR";
f("FOO quarante-deux", $foo);
g();
g;
undef $expected; &g; # $_ not passed
+BEGIN { $SIG{__WARN__} = sub {} }
{ $expected = my $_ = "bar"; g() }
+BEGIN { $SIG{__WARN__} = undef }
eval q{ sub wrong1 (_$); wrong1(1,2) };
like( $@, qr/Malformed prototype for main::wrong1/, 'wrong1' );
double();
is( $_, 42, '$_ is modifiable' );
{
+ BEGIN { $SIG{__WARN__} = sub {} }
my $_ = 22;
+ BEGIN { $SIG{__WARN__} = undef }
double();
is( $_, 44, 'my $_ is modifiable' );
}
$m1 = '$g1';
$foo =~ s//$m1/ee;
EXPECT
+Use of my $_ is deprecated at - line 16.
Use of uninitialized value $_ in pattern match (m//) at - line 5.
Use of uninitialized value $m1 in regexp compilation at - line 6.
Use of uninitialized value $_ in pattern match (m//) at - line 6.
op.c AOK
+ Use of my $_ is deprecated
+ my $_ ;
+
Found = in conditional, should be ==
1 if $a = 1 ;
__END__
# op.c
+use warnings 'deprecated' ;
+my $_;
+CORE::state $_;
+no warnings 'deprecated' ;
+my $_;
+CORE::state $_;
+EXPECT
+Use of my $_ is deprecated at - line 3.
+Use of state $_ is deprecated at - line 4.
+########
+# op.c
use warnings 'syntax' ;
1 if $a = 1 ;
1 if $a
# works in all cases.
undef $_;
{
+ no warnings 'deprecated';
my $_ = $in;
is &{"CORE::$o"}(), $out, "&$o with no args uses lexical \$_";
}
my $r;
$r = sub {
if($_[0]) {
+ no warnings 'deprecated';
my $_ = $in;
is &{"CORE::$o"}(), $out,
"&$o with no args uses the right lexical \$_ under recursion";
}
};
&$r(0);
+ no warnings 'deprecated';
my $_ = $in;
eval {
is "CORE::$o"->(), $out, "&$o with the right lexical \$_ in an eval"
my $warnings;
local $SIG{__WARN__} = sub { ++$warnings };
+ no warnings 'deprecated';
my $_ = 'Phoo';
ok &mymkdir(), '&mkdir';
like <*>, qr/^phoo(.DIR)?\z/i, 'mkdir works with implicit $_';
END
{
+ no warnings 'deprecated';
my $_ = qq($Perl -le "print 'ok'");
is( readpipe, "ok\n", 'readpipe default argument' );
}
$_ = 'lfrulb';
{
+ no warnings 'deprecated';
my $_ = 'blurfl';
ok(mkdir);
ok(-d);
}
use strict;
-no warnings 'misc';
+no warnings 'misc', 'deprecated';
$_ = 'global';
is($_, 'global', '$_ initial value');
}
{
+ no warnings 'deprecated';
my $_ = 'bar.pm';
require;
is( $r, 'bar.pm' );
{
# Lexical $_.
+ no warnings 'deprecated';
sub blurp { my $_ = shift; reverse }
is(blurp("foo"), "oof", 'reversal of default variable in function');
my $First = ucfirst $first;
$_ = "bambam";
foreach my $flint (@stones) {
+ no warnings 'deprecated';
state $_ = $flint;
is $_, $first, 'state $_';
ok /$first/, '/.../ binds to $_';
sub check_outside1 { is($_, "inside", "\$_ is not lexically scoped") }
{
+ no warnings 'deprecated';
my $_ = "outside";
given("inside") { check_outside2() }
sub check_outside2 {
# Make sure it still works with a lexical $_:
{
+ no warnings 'deprecated';
my $_;
my $test = "explicit comparison with lexical \$_";
my $twenty_five = 25;
{
my $first = 1;
+ no warnings 'deprecated';
my $_;
for (1, "two") {
when ("two") {
{
my $first = 1;
+ no warnings 'deprecated';
my $_;
for $_ (1, "two") {
when ("two") {
{
my $first = 1;
+ no warnings 'deprecated';
for my $_ (1, "two") {
when ("two") {
is($first, 0, "Lexical loop: second");
{
sub f1 {
+ no warnings 'deprecated';
my $_;
given(3) {
return sub { $_ } # close over lexical $_
sub DESTROY { $d++ };
sub f2 {
+ no warnings 'deprecated';
my $_ = 5;
given(bless [7]) {
::is($_->[0], 7, "is [7]");
{
# Test for keys in %+ and %-
my $message = 'Test keys in %+ and %-';
- no warnings 'uninitialized';
+ no warnings 'uninitialized', 'deprecated';
my $_ = "abcdef";
/(?<foo>a)|(?<foo>b)/;
is((join ",", sort keys %+), "foo", $message);
{
# length() on captures, the numbered ones end up in Perl_magic_len
+ no warnings 'deprecated';
my $_ = "aoeu \xe6var ook";
/^ \w+ \s (?<eek>\S+)/x;
{
my $message = '$REGMARK in replacement; Bug 49190';
our $REGMARK;
+ no warnings 'deprecated';
my $_ = "A";
ok(s/(*:B)A/$REGMARK/, $message);
is($_, "B", $message);
is $output, "5\n1: 5\n2: 5\n", '$a_match_var =~ /$qr/';
}
+no warnings 'deprecated';
for my $_($'){
my $output = '';
my $rx = qr/o/;