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.
144 # Check scope of pragma with eval
155 # Check scope of pragma with eval
164 Global symbol "$joe" requires explicit package name at - line 6.
165 Execution of - aborted due to compilation errors.
168 # Check scope of pragma with eval
176 Global symbol "$joe" requires explicit package name at - line 5.
177 Global symbol "$joe" requires explicit package name at - line 8.
178 Execution of - aborted due to compilation errors.
181 # Check scope of pragma with eval
190 Variable "$joe" is not imported at - line 9.
191 Global symbol "$joe" requires explicit package name at - line 9.
192 Execution of - aborted due to compilation errors.
195 # Check scope of pragma with eval
205 # Check scope of pragma with eval
212 Global symbol "$joe" requires explicit package name at (eval 1) line 3.
215 # Check scope of pragma with eval
221 Global symbol "$joe" requires explicit package name at (eval 1) line 2.
224 # Check scope of pragma with eval
232 Global symbol "$joe" requires explicit package name at - line 8.
233 Execution of - aborted due to compilation errors.
236 # Check if multiple evals produce same errors
238 my $ret = eval q{ print $x; };
240 print "ok 1\n" unless defined $ret;
241 $ret = eval q{ print $x; };
243 print "ok 2\n" unless defined $ret;
245 Global symbol "$x" requires explicit package name at (eval 1) line 1.
247 Global symbol "$x" requires explicit package name at (eval 2) line 1.
251 # strict vars with outer our - no error
263 # strict vars with inner our - no error
273 # strict vars with outer our, inner use - no error
283 # strict vars with nested our - no error
295 # strict vars with elapsed our - error
303 Variable "$fred" is not imported at - line 8.
304 Global symbol "$fred" requires explicit package name at - line 8.
305 Execution of - aborted due to compilation errors.
308 # nested our with local - no error
315 print our $fred,"\n";
321 # "nailed" our declaration visibility across package boundaries
331 # multiple our declarations in same scope, different packages, no warning
343 # multiple our declarations in same scope, same package, warning
350 "our" variable $foo masks earlier declaration in same scope at - line 7.
353 # multiple our declarations in same scope, same package, warning
363 "our" variable $foo redeclared at - line 7.
364 (Did you mean "local" instead of "our"?)
365 Name "Foo::foo" used only once: possible typo at - line 9.