1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
Check existing $^W functionality
__END__
# warnable code, warnings disabled
$a =+ 3 ;
EXPECT
########
-w
# warnable code, warnings enabled via command line switch
$c =+ 3 ;
EXPECT
Reversed += operator at - line 3.
Name "main::c" used only once: possible typo at - line 3.
########
#! perl -w
# warnable code, warnings enabled via #! line
$c =+ 3 ;
EXPECT
Reversed += operator at - line 3.
Name "main::c" used only once: possible typo at - line 3.
########
# warnable code, warnings enabled via compile time $^W
BEGIN { $^W = 1 }
$c =+ 3 ;
EXPECT
Reversed += operator at - line 4.
Name "main::c" used only once: possible typo at - line 4.
########
-w
# warnable code, warnings enabled via command line switch
use utf8;
use open qw( :utf8 :std );
$Ằ =+ 3 ;
EXPECT
Reversed += operator at - line 5.
Name "main::Ằ" used only once: possible typo at - line 5.
########
#! perl -w
# warnable code, warnings enabled via #! line
use utf8;
use open qw( :utf8 :std );
$Ằ =+ 3 ;
EXPECT
Reversed += operator at - line 5.
Name "main::Ằ" used only once: possible typo at - line 5.
########
# warnable code, warnings enabled via compile time $^W
BEGIN { $^W = 1 }
use utf8;
use open qw( :utf8 :std );
$Ằ =+ 3 ;
EXPECT
Reversed += operator at - line 6.
Name "main::Ằ" used only once: possible typo at - line 6.
########
# compile-time warnable code, warnings enabled via runtime $^W
# so no warning printed.
$^W = 1 ;
$a =+ 3 ;
EXPECT
########
# warnable code, warnings enabled via runtime $^W
$^W = 1 ;
my $b ; chop $b ;
EXPECT
Use of uninitialized value $b in scalar chop at - line 4.
########
# warnings enabled at compile time, disabled at run time
BEGIN { $^W = 1 }
$^W = 0 ;
my $b ; chop $b ;
EXPECT
########
# warnings disabled at compile time, enabled at run time
BEGIN { $^W = 0 }
$^W = 1 ;
my $b ; chop $b ;
EXPECT
Use of uninitialized value $b in scalar chop at - line 5.
########
-w
--FILE-- abcd
my $b ; chop $b ;
1 ;
--FILE--
require "./abcd";
EXPECT
Use of uninitialized value $b in scalar chop at ./abcd line 1.
########
--FILE-- abcd
my $b ; chop $b ;
1 ;
--FILE--
#! perl -w
require "./abcd";
EXPECT
Use of uninitialized value $b in scalar chop at ./abcd line 1.
########
--FILE-- abcd
my $b ; chop $b ;
1 ;
--FILE--
$^W =1 ;
require "./abcd";
EXPECT
Use of uninitialized value $b in scalar chop at ./abcd line 1.
########
--FILE-- abcd
$^W = 0;
my $b ; chop $b ;
1 ;
--FILE--
$^W =1 ;
require "./abcd";
EXPECT
########
--FILE-- abcd
$^W = 1;
1 ;
--FILE--
$^W =0 ;
require "./abcd";
my $b ; chop $b ;
EXPECT
Use of uninitialized value $b in scalar chop at - line 3.
########
$^W = 1;
eval 'my $b ; chop $b ;' ;
print $@ ;
EXPECT
Use of uninitialized value $b in scalar chop at (eval 1) line 1.
########
eval '$^W = 1;' ;
print $@ ;
my $b ; chop $b ;
EXPECT
Use of uninitialized value $b in scalar chop at - line 4.
########
eval {$^W = 1;} ;
print $@ ;
my $b ; chop $b ;
EXPECT
Use of uninitialized value $b in scalar chop at - line 4.
########
{
local ($^W) = 1;
}
my $b ; chop $b ;
EXPECT
########
my $a ; chop $a ;
{
local ($^W) = 1;
my $b ; chop $b ;
}
my $c ; chop $c ;
EXPECT
Use of uninitialized value $b in scalar chop at - line 5.
########
-w
-e undef
EXPECT
Use of uninitialized value in -e at - line 2.
########
$^W = 1 + 2 ;
EXPECT
########
$^W = $a ;
EXPECT
########
sub fred {}
$^W = fred() ;
EXPECT
########
sub fred { my $b ; chop $b ;}
{ local $^W = 0 ;
fred() ;
}
EXPECT
########
sub fred { my $b ; chop $b ;}
{ local $^W = 1 ;
fred() ;
}
EXPECT
Use of uninitialized value $b in scalar chop at - line 2.
|