In 25 words or less, what exactly is "namespace?"
Check out the perlfunc entry for package.

Hmm... that's 7 words. I'll just give you a final example:

#!/usr/bin,/perl -w $x = "MAIN"; # in default package, "main" package Foo; $x = 123; # in package "Foo", so this is $Foo::x package Bar; $x = 456; # in package "Bar", so this is $Bar::x package main; # back to normal print "\$$x = '$x'\n"; print "\$main::$x = '$main::x'\n"; print "\$Foo::$x = '$Foo::x'\n"; print "\$Bar::$x = '$Bar::x'\n";
This prints:
$MAIN = 'MAIN'
$main::MAIN = 'MAIN'
$Foo::MAIN = '123'
$Bar::MAIN = '456'
In summary: it's a way to have global variables of the same name which nevertheless don't trample on each other. That way you don't have to worry if you happen to use the same name for a variable as used in some obscure module.

Commonly modules have their own package, and the standard convention is that it's the same as the module name. use relies entirely on that convention for it's import mechanism — which is a way to make variables and subs visible unqualified across package boundaries, by making aliases to the same variables in the different packages. Thus, if you import $Foo::x into Bar, then $Bar::x will point to the same variable as $Foo::x does. Any modification of one will be reflected in a change in the other.

You're probably familiar with that effect, but you likely didn't realise how simple the underlying implementation really is. Because it is.


In reply to Re: Re: Re: More efficient reading of forms in CGI with CGI::Lite by bart
in thread More efficient reading of forms in CGI by bradcathey

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.