1 Check strict vars functionality
5 # no strict, should build & run ok.
14 use strict qw(subs refs) ;
27 # strict vars - no error
29 use vars qw( $freddy) ;
30 BEGIN { *freddy = \$joe::shmoe; }
36 # strict vars - no error
38 use vars qw( $freddy) ;
52 Global symbol "$fred" requires explicit package name (did you forget to declare "my $fred"?) at - line 4.
53 Execution of - aborted due to compilation errors.
60 Global symbol "$fred" requires explicit package name (did you forget to declare "my $fred"?) at - line 4.
61 Execution of - aborted due to compilation errors.
68 Global symbol "$fred" requires explicit package name (did you forget to declare "my $fred"?) at - line 4.
69 Execution of - aborted due to compilation errors.
72 # Check compile time scope of strict vars pragma
80 Variable "$joe" is not imported at - line 8.
81 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at - line 8.
82 Execution of - aborted due to compilation errors.
85 # Check compile time scope of strict vars pragma
88 use open qw( :utf8 :std );
95 Variable "$jòè" is not imported at - line 10.
96 Global symbol "$jòè" requires explicit package name (did you forget to declare "my $jòè"?) at - line 10.
97 Execution of - aborted due to compilation errors.
100 # Check compile time scope of strict vars pragma
108 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at - line 6.
109 Execution of - aborted due to compilation errors.
140 Variable "$joe" is not imported at ./abc line 2.
141 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at ./abc line 2.
142 Compilation failed in require at - line 2.
148 use open qw( :utf8 :std );
153 use open qw( :utf8 :std );
157 Variable "$jòè" is not imported at ./abc line 4.
158 Global symbol "$jòè" requires explicit package name (did you forget to declare "my $jòè"?) at ./abc line 4.
159 Compilation failed in require at - line 4.
170 Variable "$joe" is not imported at abc.pm line 2.
171 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at abc.pm line 2.
172 Compilation failed in require at - line 2.
173 BEGIN failed--compilation aborted at - line 2.
179 use open qw( :utf8 :std );
184 use open qw( :utf8 :std );
188 Variable "$jòè" is not imported at abc.pm line 4.
189 Global symbol "$jòè" requires explicit package name (did you forget to declare "my $jòè"?) at abc.pm line 4.
190 Compilation failed in require at - line 4.
191 BEGIN failed--compilation aborted at - line 4.
197 $a = 1;$f = 1;$k = 1; # just to get beyond the limit...
198 $b = 1;$g = 1;$l = 1;
199 $c = 1;$h = 1;$m = 1;
200 $d = 1;$i = 1;$n = 1;
201 $e = 1;$j = 1;$o = 1;
206 Global symbol "$f" requires explicit package name (did you forget to declare "my $f"?) at abc.pm line 3.
207 Global symbol "$k" requires explicit package name (did you forget to declare "my $k"?) at abc.pm line 3.
208 Global symbol "$g" requires explicit package name (did you forget to declare "my $g"?) at abc.pm line 4.
209 Global symbol "$l" requires explicit package name (did you forget to declare "my $l"?) at abc.pm line 4.
210 Global symbol "$c" requires explicit package name (did you forget to declare "my $c"?) at abc.pm line 5.
211 Global symbol "$h" requires explicit package name (did you forget to declare "my $h"?) at abc.pm line 5.
212 Global symbol "$m" requires explicit package name (did you forget to declare "my $m"?) at abc.pm line 5.
213 Global symbol "$d" requires explicit package name (did you forget to declare "my $d"?) at abc.pm line 6.
214 Global symbol "$i" requires explicit package name (did you forget to declare "my $i"?) at abc.pm line 6.
215 Global symbol "$n" requires explicit package name (did you forget to declare "my $n"?) at abc.pm line 6.
216 Global symbol "$e" requires explicit package name (did you forget to declare "my $e"?) at abc.pm line 7.
217 Global symbol "$j" requires explicit package name (did you forget to declare "my $j"?) at abc.pm line 7.
218 Global symbol "$o" requires explicit package name (did you forget to declare "my $o"?) at abc.pm line 7.
219 Global symbol "$p" requires explicit package name (did you forget to declare "my $p"?) at abc.pm line 8.
220 Illegal binary digit '2' at abc.pm line 8, at end of line
221 abc.pm has too many errors.
222 Compilation failed in require at - line 1.
223 BEGIN failed--compilation aborted at - line 1.
226 # Check scope of pragma with eval
237 # Check scope of pragma with eval
246 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at - line 6.
247 Execution of - aborted due to compilation errors.
250 # Check scope of pragma with eval
258 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at - line 5.
259 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at - line 8.
260 Execution of - aborted due to compilation errors.
263 # Check scope of pragma with eval
272 Variable "$joe" is not imported at - line 9.
273 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at - line 9.
274 Execution of - aborted due to compilation errors.
277 # Check scope of pragma with eval
280 use open qw( :utf8 :std );
288 Variable "$jòè" is not imported at - line 11.
289 Global symbol "$jòè" requires explicit package name (did you forget to declare "my $jòè"?) at - line 11.
290 Execution of - aborted due to compilation errors.
293 # Check scope of pragma with eval
303 # Check scope of pragma with eval
310 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at (eval 1) line 3.
313 # Check scope of pragma with eval
319 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at (eval 1) line 2.
322 # Check scope of pragma with eval
330 Global symbol "$joe" requires explicit package name (did you forget to declare "my $joe"?) at - line 8.
331 Execution of - aborted due to compilation errors.
334 # Check if multiple evals produce same errors
336 my $ret = eval q{ print $x; };
338 print "ok 1\n" unless defined $ret;
339 $ret = eval q{ print $x; };
341 print "ok 2\n" unless defined $ret;
343 Global symbol "$x" requires explicit package name (did you forget to declare "my $x"?) at (eval 1) line 1.
345 Global symbol "$x" requires explicit package name (did you forget to declare "my $x"?) at (eval 2) line 1.
349 # strict vars with outer our - no error
361 # strict vars with inner our - no error
371 # strict vars with outer our, inner use - no error
381 # strict vars with nested our - no error
393 # strict vars with elapsed our - error
401 Variable "$fred" is not imported at - line 8.
402 Global symbol "$fred" requires explicit package name (did you forget to declare "my $fred"?) at - line 8.
403 Execution of - aborted due to compilation errors.
406 # strict vars with elapsed our - error
409 use open qw( :utf8 :std );
416 Variable "$frèd" is not imported at - line 10.
417 Global symbol "$frèd" requires explicit package name (did you forget to declare "my $frèd"?) at - line 10.
418 Execution of - aborted due to compilation errors.
421 # nested our with local - no error
428 print our $fred,"\n";
434 # "nailed" our declaration visibility across package boundaries
444 # multiple our declarations in same scope, different packages, no warning
456 # multiple our declarations in same scope, same package, warning
463 "our" variable $foo redeclared at - line 7.
466 # multiple our declarations in same scope, same package, warning
479 "our" variable $foo redeclared at - line 9.
480 (Did you mean "local" instead of "our"?)
481 "our" variable $foo redeclared at - line 10.
487 # check if our variables are introduced correctly in readline()
491 open $FH, "abc" or die "Can't open 'abc': $!";
498 # Make sure the strict vars failure still occurs
499 # now that the '@i should be written as \@i' failure does not occur
500 # 20000522 mjd@plover.com (MJD)
505 Global symbol "@i_like_crackers" requires explicit package name (did you forget to declare "my @i_like_crackers"?) at - line 7.
506 Execution of - aborted due to compilation errors.
509 # [perl #21914] New bug > 5.8.0. Used to dump core.
513 Global symbol "@k" requires explicit package name (did you forget to declare "my @k"?) at - line 4.
514 Global symbol "$k" requires explicit package name (did you forget to declare "my $k"?) at - line 4.
515 Execution of - aborted due to compilation errors.
517 # [perl #26910] hints not propagated into (?{...})
521 Global symbol "$foo" requires explicit package name (did you forget to declare "my $foo"?) at - line 3.
522 Execution of - aborted due to compilation errors.
524 # Regex compilation errors weren't UTF-8 clean.
527 use open qw( :utf8 :std );
530 Global symbol "$fòò" requires explicit package name (did you forget to declare "my $fòò"?) at - line 5.
531 Execution of - aborted due to compilation errors.
533 # [perl #73712] 'Variable is not imported' should be suppressible
540 # [perl #112316] strict vars getting confused by nulls
541 # Assigning to a package whose name contains a null
542 BEGIN { *Foo:: = *{"foo\0bar::"} }
546 eval 'package Foo; @bar = 1' or die;
549 # [perl #112316] strict vars getting confused by nulls
550 # Assigning from within a package whose name contains a null
551 BEGIN { *Foo:: = *{"foo\0bar::"} }
555 eval 'package foo; @bar = 1' or die;
558 # [perl #112316] strict vars getting confused by nulls
559 # Assigning from one null package to another, with a common prefix
560 BEGIN { *Foo:: = *{"foo\0foo::"};
561 *Bar:: = *{"foo\0bar::"} }
565 eval 'package Bar; @bar = 1' or die;
568 # UTF8 and Latin1 package names equivalent at the byte level
570 # ĵ in UTF-8 is the same as ĵ in Latin-1
574 eval 'package ĵ; @bar = 1' or die;