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