#strictVar.pl
use strict 'vars';
$X::foo = 1; # ok, fully qualified
my $foo = 10; # ok, my() var
# local $foo = 9; # blows up
##note:
##The local() generated a compile-time error because you just touched a global name without fully qualifying it.
##Because of their special use by sort(), the variables $a and $b are exempted from this check.
package Cinna;
our $bar; # Declares $bar in current package
$bar = 'HgS'; # ok, global declared via pragma
1;
print $Cinna::bar; #Print out the var $bar in package 'Cinna'
#輸出結果:
HgS
沒有留言:
張貼留言