velusamy has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, Perl supports to have same variable names on different packages. How Perl internally stored these variables?

Replies are listed 'Best First'.
Re: Module variables
by spmlingam (Scribe) on Dec 06, 2008 at 12:10 UTC
    The following source from Mastering Perl

    Each package has a special hash-like data structure called the symbol table, which comprises all of the typeglobs for that package. It's not a real Perl hash, but it acts like it in some ways, and its name is the package name with two colons on the end.
    This isn't a normal Perl hash, but it can accessed with the keys operator. Want to see all of the symbol names defined in the main package? simply print all the keys for this special hash:

    #!/usr/bin/perl foreach my $entry ( keys %main:: ) { print "$entry\n"; }

Re: Module variables
by lakshmananindia (Chaplain) on Dec 06, 2008 at 09:23 UTC

    The package variables will be stored in a symbol table (Not the lexical variable, declared with my). For each package, perl maintains a different symbol table. So the variables will be unique and we can access using the packagename::varname

Re: Module variables
by ikegami (Patriarch) on Dec 06, 2008 at 09:11 UTC
    Could you you explain what you mean by that? Variables are as unique as the names you give them.