in reply to Array from Data Dump

There's something very odd here. You are using $name for a reference variable and also for the variable in your foreach loop. The $_ is just going to get a stringified name like HASH(0x80579ec).

What you need is to loop over the keys of $name->{'nodes'}, as in:

foreach (keys %{$name->{nodes}}) { push @trap,$name->{'nodes'}->{$_}; }

Replies are listed 'Best First'.
Re: Re: Array from Data Dump
by Anonymous Monk on Mar 03, 2003 at 15:05 UTC
    foreach (keys %{$name->{nodes}}) { push @trap,$name->{'nodes'}->{$_}; }
    Is returning a hash ref:
    HASH(0x2138d1c) HASH(0x1fff6a8) HASH(0x1fff744) HASH(0x1fff7e0) HASH(0 +x1fff87c) HASH(0x214fc78) HASH(0x1ffd238) HASH(0x1fe336c) HASH(0x1ffd2d4) HASH(0x1ffd370) HASH(0 +x1ffd40c) HASH(0x215c52c)
      Well, of course it does if you do something like this after the loop is done:
      print join(" ",@trap),"\n";
      You said you wanted to extract your nodes, and that's what you get -- hash references to the nodes stored in @trap. If you print them, you'll get stringified references. You can use Data::Dumper on them, or dereference them to process their fields, but just printing them won't work.

      Update: Did you just want the list of node names? Then do:

      my @trap = keys %{$name->{nodes}};
        That worked,
        Thanks