Getting what's in the symbol table for a specific package is pretty easy:
#!/usr/bin/perl
package symTest;
my $variable_zero = 0;
$variable_one = 1;
$variable_two = "blue";
$variable_three = 3;
for (sort keys %symTest::)
{
print $_, "\n";
}
However, you'll notice that
$variable_zero doesn't show up in the list. That's because 'my'ed variables don't actually appear in the symbol table, so only global (and 'local') variables are listed. My guess is that it would be virtually impossible to get at the 'my' (lexical) variables (but we've got some pretty smart monks here). :-)
Also note that I put the variables in a new package(symTest); the default "main" package has a lot of stuff in it's symbol table that you probably don't want to wade through.
Impossible Robot
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.