1N/ACheck strict vars functionality
1N/A
1N/A__END__
1N/A
1N/A# no strict, should build & run ok.
1N/AFred ;
1N/Amy $fred ;
1N/A$b = "fred" ;
1N/A$a = $$b ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/Ause strict qw(subs refs) ;
1N/A$fred ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/Ause strict ;
1N/Ano strict 'vars' ;
1N/A$fred ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# strict vars - no error
1N/Ause strict 'vars' ;
1N/Ause vars qw( $freddy) ;
1N/ABEGIN { *freddy = \$joe::shmoe; }
1N/A$freddy = 2 ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# strict vars - no error
1N/Ause strict 'vars' ;
1N/Ause vars qw( $freddy) ;
1N/Alocal $abc::joe ;
1N/Amy $fred ;
1N/Amy $b = \$fred ;
1N/A$Fred::ABC = 1 ;
1N/A$freddy = 2 ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# strict vars - error
1N/Ause strict ;
1N/A$fred ;
1N/AEXPECT
1N/AGlobal symbol "$fred" requires explicit package name at - line 4.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# strict vars - error
1N/Ause strict 'vars' ;
1N/A<$fred> ;
1N/AEXPECT
1N/AGlobal symbol "$fred" requires explicit package name at - line 4.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# strict vars - error
1N/Ause strict 'vars' ;
1N/Alocal $fred ;
1N/AEXPECT
1N/AGlobal symbol "$fred" requires explicit package name at - line 4.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check compile time scope of strict vars pragma
1N/Ause strict 'vars' ;
1N/A{
1N/A no strict ;
1N/A $joe = 1 ;
1N/A}
1N/A$joe = 1 ;
1N/AEXPECT
1N/AVariable "$joe" is not imported at - line 8.
1N/AGlobal symbol "$joe" requires explicit package name at - line 8.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check compile time scope of strict vars pragma
1N/Ano strict;
1N/A{
1N/A use strict 'vars' ;
1N/A $joe = 1 ;
1N/A}
1N/A$joe = 1 ;
1N/AEXPECT
1N/AGlobal symbol "$joe" requires explicit package name at - line 6.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A--FILE-- abc
1N/A$joe = 1 ;
1N/A1;
1N/A--FILE--
1N/Ause strict 'vars' ;
1N/Arequire "./abc";
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A--FILE-- abc
1N/Ause strict 'vars' ;
1N/A1;
1N/A--FILE--
1N/Arequire "./abc";
1N/A$joe = 1 ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A--FILE-- abc
1N/Ause strict 'vars' ;
1N/A$joe = 1 ;
1N/A1;
1N/A--FILE--
1N/A$joe = 1 ;
1N/Arequire "./abc";
1N/AEXPECT
1N/AVariable "$joe" is not imported at ./abc line 2.
1N/AGlobal symbol "$joe" requires explicit package name at ./abc line 2.
1N/ACompilation failed in require at - line 2.
1N/A########
1N/A
1N/A--FILE-- abc.pm
1N/Ause strict 'vars' ;
1N/A$joe = 1 ;
1N/A1;
1N/A--FILE--
1N/A$joe = 1 ;
1N/Ause abc;
1N/AEXPECT
1N/AVariable "$joe" is not imported at abc.pm line 2.
1N/AGlobal symbol "$joe" requires explicit package name at abc.pm line 2.
1N/ACompilation failed in require at - line 2.
1N/ABEGIN failed--compilation aborted at - line 2.
1N/A########
1N/A
1N/A--FILE-- abc.pm
1N/Apackage Burp;
1N/Ause strict;
1N/A$a = 1;$f = 1;$k = 1; # just to get beyond the limit...
1N/A$b = 1;$g = 1;$l = 1;
1N/A$c = 1;$h = 1;$m = 1;
1N/A$d = 1;$i = 1;$n = 1;
1N/A$e = 1;$j = 1;$o = 1;
1N/A$p = 0b12;
1N/A--FILE--
1N/Ause abc;
1N/AEXPECT
1N/AGlobal symbol "$f" requires explicit package name at abc.pm line 3.
1N/AGlobal symbol "$k" requires explicit package name at abc.pm line 3.
1N/AGlobal symbol "$g" requires explicit package name at abc.pm line 4.
1N/AGlobal symbol "$l" requires explicit package name at abc.pm line 4.
1N/AGlobal symbol "$c" requires explicit package name at abc.pm line 5.
1N/AGlobal symbol "$h" requires explicit package name at abc.pm line 5.
1N/AGlobal symbol "$m" requires explicit package name at abc.pm line 5.
1N/AGlobal symbol "$d" requires explicit package name at abc.pm line 6.
1N/AGlobal symbol "$i" requires explicit package name at abc.pm line 6.
1N/AGlobal symbol "$n" requires explicit package name at abc.pm line 6.
1N/AGlobal symbol "$e" requires explicit package name at abc.pm line 7.
1N/AGlobal symbol "$j" requires explicit package name at abc.pm line 7.
1N/AGlobal symbol "$o" requires explicit package name at abc.pm line 7.
1N/AGlobal symbol "$p" requires explicit package name at abc.pm line 8.
1N/AIllegal binary digit '2' at abc.pm line 8, at end of line
1N/Aabc.pm has too many errors.
1N/ACompilation failed in require at - line 1.
1N/ABEGIN failed--compilation aborted at - line 1.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ano strict ;
1N/Aeval {
1N/A $joe = 1 ;
1N/A};
1N/Aprint STDERR $@;
1N/A$joe = 1 ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ano strict ;
1N/Aeval {
1N/A use strict 'vars' ;
1N/A $joe = 1 ;
1N/A};
1N/Aprint STDERR $@;
1N/A$joe = 1 ;
1N/AEXPECT
1N/AGlobal symbol "$joe" requires explicit package name at - line 6.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ause strict 'vars' ;
1N/Aeval {
1N/A $joe = 1 ;
1N/A};
1N/Aprint STDERR $@;
1N/A$joe = 1 ;
1N/AEXPECT
1N/AGlobal symbol "$joe" requires explicit package name at - line 5.
1N/AGlobal symbol "$joe" requires explicit package name at - line 8.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ause strict 'vars' ;
1N/Aeval {
1N/A no strict ;
1N/A $joe = 1 ;
1N/A};
1N/Aprint STDERR $@;
1N/A$joe = 1 ;
1N/AEXPECT
1N/AVariable "$joe" is not imported at - line 9.
1N/AGlobal symbol "$joe" requires explicit package name at - line 9.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ano strict ;
1N/Aeval '
1N/A $joe = 1 ;
1N/A'; print STDERR $@ ;
1N/A$joe = 1 ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ano strict ;
1N/Aeval q[
1N/A use strict 'vars' ;
1N/A $joe = 1 ;
1N/A]; print STDERR $@;
1N/AEXPECT
1N/AGlobal symbol "$joe" requires explicit package name at (eval 1) line 3.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ause strict 'vars' ;
1N/Aeval '
1N/A $joe = 1 ;
1N/A'; print STDERR $@ ;
1N/AEXPECT
1N/AGlobal symbol "$joe" requires explicit package name at (eval 1) line 2.
1N/A########
1N/A
1N/A# Check scope of pragma with eval
1N/Ause strict 'vars' ;
1N/Aeval '
1N/A no strict ;
1N/A $joe = 1 ;
1N/A'; print STDERR $@;
1N/A$joe = 1 ;
1N/AEXPECT
1N/AGlobal symbol "$joe" requires explicit package name at - line 8.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# Check if multiple evals produce same errors
1N/Ause strict 'vars';
1N/Amy $ret = eval q{ print $x; };
1N/Aprint $@;
1N/Aprint "ok 1\n" unless defined $ret;
1N/A$ret = eval q{ print $x; };
1N/Aprint $@;
1N/Aprint "ok 2\n" unless defined $ret;
1N/AEXPECT
1N/AGlobal symbol "$x" requires explicit package name at (eval 1) line 1.
1N/Aok 1
1N/AGlobal symbol "$x" requires explicit package name at (eval 2) line 1.
1N/Aok 2
1N/A########
1N/A
1N/A# strict vars with outer our - no error
1N/Ause strict 'vars' ;
1N/Aour $freddy;
1N/Alocal $abc::joe ;
1N/Amy $fred ;
1N/Amy $b = \$fred ;
1N/A$Fred::ABC = 1 ;
1N/A$freddy = 2 ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# strict vars with inner our - no error
1N/Ause strict 'vars' ;
1N/Asub foo {
1N/A our $fred;
1N/A $fred;
1N/A}
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# strict vars with outer our, inner use - no error
1N/Ause strict 'vars' ;
1N/Aour $fred;
1N/Asub foo {
1N/A $fred;
1N/A}
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# strict vars with nested our - no error
1N/Ause strict 'vars' ;
1N/Aour $fred;
1N/Asub foo {
1N/A our $fred;
1N/A $fred;
1N/A}
1N/A$fred ;
1N/AEXPECT
1N/A
1N/A########
1N/A
1N/A# strict vars with elapsed our - error
1N/Ause strict 'vars' ;
1N/Asub foo {
1N/A our $fred;
1N/A $fred;
1N/A}
1N/A$fred ;
1N/AEXPECT
1N/AVariable "$fred" is not imported at - line 8.
1N/AGlobal symbol "$fred" requires explicit package name at - line 8.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A
1N/A# nested our with local - no error
1N/A$fred = 1;
1N/Ause strict 'vars';
1N/A{
1N/A local our $fred = 2;
1N/A print $fred,"\n";
1N/A}
1N/Aprint our $fred,"\n";
1N/AEXPECT
1N/A2
1N/A1
1N/A########
1N/A
1N/A# "nailed" our declaration visibility across package boundaries
1N/Ause strict 'vars';
1N/Aour $foo;
1N/A$foo = 20;
1N/Apackage Foo;
1N/Aprint $foo, "\n";
1N/AEXPECT
1N/A20
1N/A########
1N/A
1N/A# multiple our declarations in same scope, different packages, no warning
1N/Ause strict 'vars';
1N/Ause warnings;
1N/Aour $foo;
1N/A${foo} = 10;
1N/Apackage Foo;
1N/Aour $foo = 20;
1N/Aprint $foo, "\n";
1N/AEXPECT
1N/A20
1N/A########
1N/A
1N/A# multiple our declarations in same scope, same package, warning
1N/Ause strict 'vars';
1N/Ause warnings;
1N/Aour $foo;
1N/A${foo} = 10;
1N/Aour $foo;
1N/AEXPECT
1N/A"our" variable $foo masks earlier declaration in same scope at - line 7.
1N/A########
1N/A
1N/A# multiple our declarations in same scope, same package, warning
1N/Ause strict 'vars';
1N/Ause warnings;
1N/A{ our $x = 1 }
1N/A{ our $x = 0 }
1N/Aour $foo;
1N/A{
1N/A our $foo;
1N/A package Foo;
1N/A our $foo;
1N/A}
1N/AEXPECT
1N/A"our" variable $foo redeclared at - line 9.
1N/A (Did you mean "local" instead of "our"?)
1N/A########
1N/A
1N/A--FILE-- abc
1N/Aok
1N/A--FILE--
1N/A# check if our variables are introduced correctly in readline()
1N/Apackage Foo;
1N/Ause strict 'vars';
1N/Aour $FH;
1N/Aopen $FH, "abc" or die "Can't open 'abc': $!";
1N/Aprint <$FH>;
1N/Aclose $FH;
1N/AEXPECT
1N/Aok
1N/A########
1N/A
1N/A# Make sure the strict vars failure still occurs
1N/A# now that the `@i should be written as \@i' failure does not occur
1N/A# 20000522 mjd@plover.com (MJD)
1N/Ause strict 'vars';
1N/Ano warnings;
1N/A"@i_like_crackers";
1N/AEXPECT
1N/AGlobal symbol "@i_like_crackers" requires explicit package name at - line 7.
1N/AExecution of - aborted due to compilation errors.
1N/A########
1N/A# [perl #26910] hints not propagated into (?{...})
1N/Ause strict 'vars';
1N/Aqr/(?{$foo++})/;
1N/AEXPECT
1N/AGlobal symbol "$foo" requires explicit package name at (re_eval 1) line 1.
1N/ACompilation failed in regexp at - line 3.