1 pp_hot.c 2 3 print() on unopened filehandle abc [pp_print] 4 $f = $a = "abc" ; print $f $a 5 6 Filehandle %s opened only for input [pp_print] 7 print STDIN "abc" ; 8 9 Filehandle %s opened only for output [pp_print] 10 $a = <STDOUT> ; 11 12 print() on closed filehandle %s [pp_print] 13 close STDIN ; print STDIN "abc" ; 14 15 uninitialized [pp_rv2av] 16 my $a = undef ; my @b = @$a 17 18 uninitialized [pp_rv2hv] 19 my $a = undef ; my %b = %$a 20 21 Odd number of elements in hash list [pp_aassign] 22 %X = (1,2,3) ; 23 24 Reference found where even-sized list expected [pp_aassign] 25 $X = [ 1 ..3 ]; 26 27 Filehandle %s opened only for output [Perl_do_readline] 28 open (FH, ">./xcv") ; 29 my $a = <FH> ; 30 31 glob failed (can't start child: %s) [Perl_do_readline] <<TODO 32 33 readline() on closed filehandle %s [Perl_do_readline] 34 close STDIN ; $a = <STDIN>; 35 36 readline() on closed filehandle %s [Perl_do_readline] 37 readline(NONESUCH); 38 39 glob failed (child exited with status %d%s) [Perl_do_readline] <<TODO 40 41 Deep recursion on subroutine \"%s\" [Perl_sub_crush_depth] 42 sub fred { fred() if $a++ < 200} fred() 43 44 Deep recursion on anonymous subroutine [Perl_sub_crush_depth] 45 $a = sub { &$a if $a++ < 200} &$a 46 47 Possible Y2K bug: about to append an integer to '19' [pp_concat] 48 $x = "19$yy\n"; 49 50 Use of reference "%s" as array index [pp_aelem] 51 $x[\1] 52 53__END__ 54# pp_hot.c [pp_print] 55use warnings 'unopened' ; 56$f = $a = "abc" ; 57print $f $a; 58no warnings 'unopened' ; 59print $f $a; 60use warnings; 61no warnings 'unopened' ; 62print $f $a; 63EXPECT 64print() on unopened filehandle abc at - line 4. 65######## 66# pp_hot.c [pp_print] 67use warnings 'io' ; 68# There is no guarantee that STDOUT is output only, or STDIN input only. 69# Certainly on some BSDs (at least FreeBSD, Darwin, BSDi) file descriptors 70# 1 and 2 are opened read/write on the tty, and the IO layers may reflect this. 71# So we must make our own file handle that is read only. 72my $file = "./xcv" ; unlink $file ; 73open (FH, ">$file") or die $! ; 74close FH or die $! ; 75die "There is no file $file" unless -f $file ; 76open (FH, "<$file") or die $! ; 77print FH "anc" ; 78open(FOO, "<&FH") or die $! ; 79print FOO "anc" ; 80no warnings 'io' ; 81print FH "anc" ; 82print FOO "anc" ; 83use warnings 'io' ; 84print FH "anc" ; 85print FOO "anc" ; 86close (FH) or die $! ; 87close (FOO) or die $! ; 88unlink $file ; 89EXPECT 90Filehandle FH opened only for input at - line 12. 91Filehandle FOO opened only for input at - line 14. 92Filehandle FH opened only for input at - line 19. 93Filehandle FOO opened only for input at - line 20. 94######## 95# pp_hot.c [pp_print] 96use warnings 'closed' ; 97close STDIN ; 98print STDIN "anc"; 99opendir STDIN, "."; 100print STDIN "anc"; 101closedir STDIN; 102no warnings 'closed' ; 103print STDIN "anc"; 104opendir STDIN, "."; 105print STDIN "anc"; 106use warnings; 107no warnings 'closed' ; 108print STDIN "anc"; 109EXPECT 110print() on closed filehandle STDIN at - line 4. 111print() on closed filehandle STDIN at - line 6. 112 (Are you trying to call print() on dirhandle STDIN?) 113######## 114# pp_hot.c [pp_print] 115# [ID 20020425.012] from Dave Steiner <steiner@bakerst.rutgers.edu> 116# This goes segv on 5.7.3 117use warnings 'closed' ; 118my $fh = *STDOUT{IO}; 119close STDOUT or die "Can't close STDOUT"; 120print $fh "Shouldn't print anything, but shouldn't SEGV either\n"; 121EXPECT 122print() on closed filehandle at - line 7. 123######## 124# pp_hot.c [pp_print] 125package foo; 126use warnings 'closed'; 127open my $fh1, "nonexistent"; 128print $fh1 42; 129open $fh2, "nonexistent"; 130print $fh2 42; 131open $bar::fh3, "nonexistent"; 132print $bar::fh3 42; 133open bar::FH4, "nonexistent"; 134print bar::FH4 42; 135EXPECT 136print() on closed filehandle $fh1 at - line 5. 137print() on closed filehandle $fh2 at - line 7. 138print() on closed filehandle $fh3 at - line 9. 139print() on closed filehandle FH4 at - line 11. 140######## 141# pp_hot.c [pp_rv2av] 142use warnings 'uninitialized' ; 143my $a = undef ; 144my @b = @$a; 145no warnings 'uninitialized' ; 146my @c = @$a; 147EXPECT 148Use of uninitialized value in array dereference at - line 4. 149######## 150# pp_hot.c [pp_rv2hv] 151use warnings 'uninitialized' ; 152my $a = undef ; 153my %b = %$a; 154no warnings 'uninitialized' ; 155my %c = %$a; 156EXPECT 157Use of uninitialized value in hash dereference at - line 4. 158######## 159# pp_hot.c [pp_aassign] 160use warnings 'misc' ; 161my %X ; %X = (1,2,3) ; 162no warnings 'misc' ; 163my %Y ; %Y = (1,2,3) ; 164EXPECT 165Odd number of elements in hash assignment at - line 3. 166######## 167# pp_hot.c [pp_aassign] 168use warnings 'misc' ; 169my %X ; %X = [1 .. 3] ; 170no warnings 'misc' ; 171my %Y ; %Y = [1 .. 3] ; 172EXPECT 173Reference found where even-sized list expected at - line 3. 174######## 175# pp_hot.c [Perl_do_readline] 176use warnings 'closed' ; 177close STDIN ; $a = <STDIN> ; 178opendir STDIN, "." ; $a = <STDIN> ; 179closedir STDIN; 180no warnings 'closed' ; 181opendir STDIN, "." ; $a = <STDIN> ; 182$a = <STDIN> ; 183EXPECT 184readline() on closed filehandle STDIN at - line 3. 185readline() on closed filehandle STDIN at - line 4. 186 (Are you trying to call readline() on dirhandle STDIN?) 187######## 188# pp_hot.c [Perl_do_readline] 189use warnings 'io' ; 190my $file = "./xcv" ; unlink $file ; 191open (FH, ">$file") or die $! ; 192my $a = <FH> ; 193no warnings 'io' ; 194$a = <FH> ; 195use warnings 'io' ; 196open(FOO, ">&FH") or die $! ; 197$a = <FOO> ; 198no warnings 'io' ; 199$a = <FOO> ; 200use warnings 'io' ; 201$a = <FOO> ; 202$a = <FH> ; 203close (FH) or die $! ; 204close (FOO) or die $! ; 205unlink $file ; 206EXPECT 207Filehandle FH opened only for output at - line 5. 208Filehandle FOO opened only for output at - line 10. 209Filehandle FOO opened only for output at - line 14. 210Filehandle FH opened only for output at - line 15. 211######## 212# pp_hot.c [Perl_sub_crush_depth] 213use warnings 'recursion' ; 214sub fred 215{ 216 fred() if $a++ < 200 217} 218{ 219 local $SIG{__WARN__} = sub { 220 die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ 221 }; 222 fred(); 223} 224EXPECT 225ok 226######## 227# pp_hot.c [Perl_sub_crush_depth] 228no warnings 'recursion' ; 229sub fred 230{ 231 fred() if $a++ < 200 232} 233{ 234 local $SIG{__WARN__} = sub { 235 die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ 236 }; 237 fred(); 238} 239EXPECT 240 241######## 242# pp_hot.c [Perl_sub_crush_depth] 243use warnings 'recursion' ; 244$b = sub 245{ 246 &$b if $a++ < 200 247} ; 248 249&$b ; 250EXPECT 251Deep recursion on anonymous subroutine at - line 5. 252######## 253# pp_hot.c [Perl_sub_crush_depth] 254no warnings 'recursion' ; 255$b = sub 256{ 257 &$b if $a++ < 200 258} ; 259 260&$b ; 261EXPECT 262######## 263# pp_hot.c [pp_concat] 264use warnings 'uninitialized'; 265my($x, $y); 266sub a { shift } 267a($x . "x"); # should warn once 268a($x . $y); # should warn twice 269$x .= $y; # should warn once 270$y .= $y; # should warn once 271EXPECT 272Use of uninitialized value in concatenation (.) or string at - line 5. 273Use of uninitialized value in concatenation (.) or string at - line 6. 274Use of uninitialized value in concatenation (.) or string at - line 6. 275Use of uninitialized value in concatenation (.) or string at - line 7. 276Use of uninitialized value in concatenation (.) or string at - line 8. 277######## 278# pp_hot.c [pp_concat] 279use warnings 'y2k'; 280use Config; 281BEGIN { 282 unless ($Config{ccflags} =~ /Y2KWARN/) { 283 print "SKIPPED\n# perl not built with -DPERL_Y2KWARN"; 284 exit 0; 285 } 286} 287my $x; 288my $yy = 78; 289$x = "19$yy\n"; 290$x = "19" . $yy . "\n"; 291$x = "319$yy\n"; 292$x = "319" . $yy . "\n"; 293$yy = 19; 294$x = "ok $yy\n"; 295$yy = 9; 296$x = 1 . $yy; 297no warnings 'y2k'; 298$x = "19$yy\n"; 299$x = "19" . $yy . "\n"; 300EXPECT 301Possible Y2K bug: about to append an integer to '19' at - line 12. 302Possible Y2K bug: about to append an integer to '19' at - line 13. 303######## 304# pp_hot.c [pp_aelem] 305{ 306use warnings 'misc'; 307print $x[\1]; 308} 309{ 310no warnings 'misc'; 311print $x[\1]; 312} 313 314EXPECT 315OPTION regex 316Use of reference ".*" as array index at - line 4. 317######## 318# pp_hot.c [pp_aelem] 319package Foo;use overload q("") => sub {};package main;$a = bless {}, "Foo"; 320$b = {}; 321{ 322use warnings 'misc'; 323print $x[$a]; 324print $x[$b]; 325} 326{ 327no warnings 'misc'; 328print $x[$a]; 329print $x[$b]; 330} 331 332EXPECT 333OPTION regex 334Use of reference ".*" as array index at - line 7. 335