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.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.