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;
155 BEGIN { $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3; }
158 Global symbol "$f" requires explicit package name at abc.pm line 3.
159 Global symbol "$k" requires explicit package name at abc.pm line 3.
160 Global symbol "$g" requires explicit package name at abc.pm line 4.
161 Global symbol "$l" requires explicit package name at abc.pm line 4.
162 Global symbol "$c" requires explicit package name at abc.pm line 5.
163 Global symbol "$h" requires explicit package name at abc.pm line 5.
164 Global symbol "$m" requires explicit package name at abc.pm line 5.
165 Global symbol "$d" requires explicit package name at abc.pm line 6.
166 Global symbol "$i" requires explicit package name at abc.pm line 6.
167 Global symbol "$n" requires explicit package name at abc.pm line 6.
168 Global symbol "$e" requires explicit package name at abc.pm line 7.
169 Global symbol "$j" requires explicit package name at abc.pm line 7.
170 Global symbol "$o" requires explicit package name at abc.pm line 7.
171 Global symbol "$p" requires explicit package name at abc.pm line 8.
172 Illegal binary digit '2' at abc.pm line 8, at end of line
173 abc.pm has too many errors.
174 Compilation failed in require at - line 3.
175 BEGIN failed--compilation aborted at - line 3.
178 # Check scope of pragma with eval
189 # Check scope of pragma with eval
198 Global symbol "$joe" requires explicit package name at - line 6.
199 Execution of - aborted due to compilation errors.
202 # Check scope of pragma with eval
210 Global symbol "$joe" requires explicit package name at - line 5.
211 Global symbol "$joe" requires explicit package name at - line 8.
212 Execution of - aborted due to compilation errors.
215 # Check scope of pragma with eval
224 Variable "$joe" is not imported at - line 9.
225 Global symbol "$joe" requires explicit package name at - line 9.
226 Execution of - aborted due to compilation errors.
229 # Check scope of pragma with eval
239 # Check scope of pragma with eval
246 Global symbol "$joe" requires explicit package name at (eval 1) line 3.
249 # Check scope of pragma with eval
255 Global symbol "$joe" requires explicit package name at (eval 1) line 2.
258 # Check scope of pragma with eval
266 Global symbol "$joe" requires explicit package name at - line 8.
267 Execution of - aborted due to compilation errors.
270 # Check if multiple evals produce same errors
272 my $ret = eval q{ print $x; };
274 print "ok 1\n" unless defined $ret;
275 $ret = eval q{ print $x; };
277 print "ok 2\n" unless defined $ret;
279 Global symbol "$x" requires explicit package name at (eval 1) line 1.
281 Global symbol "$x" requires explicit package name at (eval 2) line 1.
285 # strict vars with outer our - no error
297 # strict vars with inner our - no error
307 # strict vars with outer our, inner use - no error
317 # strict vars with nested our - no error
329 # strict vars with elapsed our - error
337 Variable "$fred" is not imported at - line 8.
338 Global symbol "$fred" requires explicit package name at - line 8.
339 Execution of - aborted due to compilation errors.
342 # nested our with local - no error
349 print our $fred,"\n";
355 # "nailed" our declaration visibility across package boundaries
365 # multiple our declarations in same scope, different packages, no warning
377 # multiple our declarations in same scope, same package, warning
384 "our" variable $foo masks earlier declaration in same scope at - line 7.
387 # multiple our declarations in same scope, same package, warning
399 "our" variable $foo redeclared at - line 9.
400 (Did you mean "local" instead of "our"?)
401 Name "Foo::foo" used only once: possible typo at - line 11.
404 # Make sure the strict vars failure still occurs
405 # now that the `@i should be written as \@i' failure does not occur
406 # 20000522 mjd@plover.com (MJD)
411 Global symbol "@i_like_crackers" requires explicit package name at - line 7.
412 Execution of - aborted due to compilation errors.