use strict; use warnings; use Data::Dumper; our $VAR=5.0; sub printit{print "Package Main VAR=$VAR\n";} package A; our $VAR=2.0; sub printit{print "Package A VAR=$VAR\n";} package B; our $VAR=3.0; sub printit{print "Package B VAR=$VAR\n";} package C; our $VAR=4.0; sub printit{print "Package C VAR=$VAR\n";} package main; A::printit; B::printit; C::printit; printit; print "Package Main VAR=$VAR\n";
Output of the above script it.... Package A VAR=2 Package B VAR=3 Package C VAR=4 Package Main VAR=5 Package Main VAR=4
COMMENT : I am confused to see the result. As per my understanding, the last line of the result should be same as second last line. Please help. Thank you.
In reply to package variable scope by santoshprasad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |