in reply to look up the symbol table of a variable
Try this:
The above makes use of a symbolic reference (the string "MyPackage::"), therefore, I turn off strict "refs" in the enclosing block. In the call to keys it is necessary to enclose "package" in curlies, otherwise perl will think you are talking about the package variable $package:: (no pun intended) which is distinct from the lexical $package.my $package = "MyPackage"; { no strict 'refs'; for my $sym ( keys %{ "${package}::" } ) { print "$sym\n"; } }
the lowliest monk
|
|---|