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 at - line 4.
53 Execution of - aborted due to compilation errors.
60 Global symbol "$fred" requires explicit package name at - line 4.
61 Execution of - aborted due to compilation errors.
68 Global symbol "$fred" requires explicit package name 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 at - line 8.
82 Execution of - aborted due to compilation errors.
85 # Check compile time scope of strict vars pragma
93 Global symbol "$joe" requires explicit package name at - line 6.
94 Execution of - aborted due to compilation errors.
125 Variable "$joe" is not imported at ./abc line 2.
126 Global symbol "$joe" requires explicit package name at ./abc line 2.
127 Compilation failed in require at - line 2.
138 Variable "$joe" is not imported at abc.pm line 2.
139 Global symbol "$joe" requires explicit package name at abc.pm line 2.
140 Compilation failed in require at - line 2.
141 BEGIN failed--compilation aborted at - line 2.
147 $a = 1;$f = 1;$k = 1; # just to get beyond the limit...
148 $b = 1;$g = 1;$l = 1;
149 $c = 1;$h = 1;$m = 1;
150 $d = 1;$i = 1;$n = 1;
151 $e = 1;$j = 1;$o = 1;
156 Global symbol "$f" requires explicit package name at abc.pm line 3.
157 Global symbol "$k" requires explicit package name at abc.pm line 3.
158 Global symbol "$g" requires explicit package name at abc.pm line 4.
159 Global symbol "$l" requires explicit package name at abc.pm line 4.
160 Global symbol "$c" requires explicit package name at abc.pm line 5.
161 Global symbol "$h" requires explicit package name at abc.pm line 5.
162 Global symbol "$m" requires explicit package name at abc.pm line 5.
163 Global symbol "$d" requires explicit package name at abc.pm line 6.
164 Global symbol "$i" requires explicit package name at abc.pm line 6.
165 Global symbol "$n" requires explicit package name at abc.pm line 6.
166 Global symbol "$e" requires explicit package name at abc.pm line 7.
167 Global symbol "$j" requires explicit package name at abc.pm line 7.
168 Global symbol "$o" requires explicit package name at abc.pm line 7.
169 Global symbol "$p" requires explicit package name at abc.pm line 8.
170 Illegal binary digit '2' at abc.pm line 8, at end of line
171 abc.pm has too many errors.
172 Compilation failed in require at - line 1.
173 BEGIN failed--compilation aborted at - line 1.
176 # Check scope of pragma with eval
187 # Check scope of pragma with eval
196 Global symbol "$joe" requires explicit package name at - line 6.
197 Execution of - aborted due to compilation errors.
200 # Check scope of pragma with eval
208 Global symbol "$joe" requires explicit package name at - line 5.
209 Global symbol "$joe" requires explicit package name at - line 8.
210 Execution of - aborted due to compilation errors.
213 # Check scope of pragma with eval
222 Variable "$joe" is not imported at - line 9.
223 Global symbol "$joe" requires explicit package name at - line 9.
224 Execution of - aborted due to compilation errors.
227 # Check scope of pragma with eval
237 # Check scope of pragma with eval
244 Global symbol "$joe" requires explicit package name at (eval 1) line 3.
247 # Check scope of pragma with eval
253 Global symbol "$joe" requires explicit package name at (eval 1) line 2.
256 # Check scope of pragma with eval
264 Global symbol "$joe" requires explicit package name at - line 8.
265 Execution of - aborted due to compilation errors.
268 # Check if multiple evals produce same errors
270 my $ret = eval q{ print $x; };
272 print "ok 1\n" unless defined $ret;
273 $ret = eval q{ print $x; };
275 print "ok 2\n" unless defined $ret;
277 Global symbol "$x" requires explicit package name at (eval 1) line 1.
279 Global symbol "$x" requires explicit package name at (eval 2) line 1.
283 # strict vars with outer our - no error
295 # strict vars with inner our - no error
305 # strict vars with outer our, inner use - no error
315 # strict vars with nested our - no error
327 # strict vars with elapsed our - error
335 Variable "$fred" is not imported at - line 8.
336 Global symbol "$fred" requires explicit package name at - line 8.
337 Execution of - aborted due to compilation errors.
340 # nested our with local - no error
347 print our $fred,"\n";
353 # "nailed" our declaration visibility across package boundaries
363 # multiple our declarations in same scope, different packages, no warning
375 # multiple our declarations in same scope, same package, warning
382 "our" variable $foo masks earlier declaration in same scope at - line 7.
385 # multiple our declarations in same scope, same package, warning
397 "our" variable $foo redeclared at - line 9.
398 (Did you mean "local" instead of "our"?)
404 # check if our variables are introduced correctly in readline()
408 open $FH, "abc" or die "Can't open 'abc': $!";
415 # Make sure the strict vars failure still occurs
416 # now that the `@i should be written as \@i' failure does not occur
417 # 20000522 mjd@plover.com (MJD)
422 Global symbol "@i_like_crackers" requires explicit package name at - line 7.
423 Execution of - aborted due to compilation errors.
426 # [perl #21914] New bug > 5.8.0. Used to dump core.
430 Global symbol "@k" requires explicit package name at - line 4.
431 Global symbol "$k" requires explicit package name at - line 4.
432 Execution of - aborted due to compilation errors.
434 # [perl #26910] hints not propagated into (?{...})
438 Global symbol "$foo" requires explicit package name at (re_eval 1) line 1.
439 Compilation failed in regexp at - line 3.