On Fri, 2003-01-17 at 13:45, John Saylor wrote:
> Hi
> 
> I have a project where I am trying to dump all the variable names and
> values in a given package namespace. I can get all the variable names
> OK, it's just getting the values from those names that I am not able to
> do.
> 
> I have some code like this:
> foreach $key ( keys %main::Package:: ) {
>   $val = $WW::Package::{$key};
>   print "$key\t$val\n";
> }
> 
> but all I get is typeglobs.
> 
> Any help is appreciated.

Dereference the typeglob:

foreach $key ( keys %main::Package:: ) {
  my $scalar   = $$main::Package::{$key};
  my $arrayref = \@$main::Package::{$key};
  my $hashref  = \%$main::Package::{$key};
}

-- 
John West                          Software Consultant, Perl Monk
Corporate Technologies, Inc.                         781-791-2118

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to