Ah, perl variables. See perldata for starters.
Perl has global variables (and special global variables, see perlvar) which live in the symbol table of a package (or the "anypackage", i.e. they are available everywhere); then aliased specials, localized globals, lexically scoped, masked and state variables. Am I missing some?
The perl documentation provides a wealth of information about each variable kind. Start with perldata, look up my, our, local. The monastery has good writeups about various issues regarding each variable kind, i.e. my/local, space/time (was: Re: The difference between my and local).
By default, without useing strict, each variable is autovivified upon first use and its identifier stored in the symbol table of the current package, which defaults to main. The symbol table itself is a hash (default %main:: - note the two colons which are package identifiers/delimiters). The variables in each package are not globals - not even the variables in package main:
perl -le '$foo ="bar"; package Bar; print ">$foo<";package main; print + ">$foo<"' >< >bar<
Well... that's for starters. I wish you a good time grinding manual pages and exploring the depths of this Monastery.
In reply to Re: does perl have a concept of "int main()"? (variable scoping question)
by shmem
in thread does perl have a concept of "int main()"? (variable scoping question)
by Special_K
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |