Stop that train! Perl has global variables. What you may be thinking is that each package global exists in its own namespace, so $foo in package Foo is a distinct entity from $foo in package Bar. But all that means is that while you're in package Bar, $foo refers to $Bar::foo. A variable declared in a package (with use vars or, in 5.6, our) is global within that package (e.g. every subroutine in that package can see and modify that variable (unless it's masked by a my declaration -- i.e. within a block (or, if used outside of a block, a file), use of $foo will refer to the variable declared with my $foo)
You may have been thinking that under use strict 'vars', you need to declare variables with my before you can refer to them, but that's not really true (e.g. you can use vars -- for the skinny, see strict (even better the man page on your system) or tye's writeup strict.pm)
Philosophy can be made out of anything. Or less -- Jerry A. Fodor
In reply to Re: Re: variable passing....
by arturo
in thread variable passing....
by lelak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |