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

Does anyone know if it's possible to grab the contents of syntax values ($dump->{'nodes'}->{'xylanXIPGMAPLastTrapReason'}->{'syntax'}->{'values'})without knowing the value of the keys?
'xylanXIPGMAPLastTrapReason' => { 'status' => 'mandatory', 'OID' => [ '1', '3', '6', '1', '4', '1', '800', '2', '20', '1', '5' ], 'description' => '"Reason for last GMAP update to not be applied +. Valid reasons are: 0 - No trap has been sent 1 - Target group is an authenticated group 2 - Update would conflict with a binding rule 3 - Update would create two different group entries for the same protocol 4 - Update would create two different protocol entries for the same group 5 - Target group is not mobile"', 'syntax' => { 'values' => { '0' => 'no-trap-sent', '1' => 'authenticated-group', '2' => 'conflicting-binding-rule', '3' => 'same-proto-different-groups-conflict', '4' => 'same-group-different-protocols-conflict', '5' => 'non-mobile-group' }, 'type' => 'INTEGER' }, 'access' => 'read-only', 'oid' => [ 'iso', 'org', 'dod', 'internet', 'private', 'enterprises', 'xylan', 'xylanArch', 'xylanXIPArch', 'xylanXIPGMAPconfig', '5' ], 'type' => 'OBJECT-TYPE' },
I'm trying to get both the key value pairs
'0' => 'no-trap-sent', '1' => 'authenticated-group', '2' => 'conflicting-binding-rule', '3' => 'same-proto-different-groups-conflict', '4' => 'same-group-different-protocols-conflict', '5' => 'non-mobile-group'

Replies are listed 'Best First'.
•Re: Data Dumper Parse
by merlyn (Sage) on Mar 11, 2003 at 14:44 UTC
Re: Data Dumper Parse
by jasonk (Parson) on Mar 11, 2003 at 14:47 UTC

    You could just iterate through them:

    foreach(keys %{$x->{'xylanXIPGMAPLastTrapReason'}->{'syntax'}->{'value +s'}}) { print "$_ = ".$x->{'xylanXIPGMAPLastTrapReason'}->{'syntax +'}->{'values'}->{$_}."\n"; }

    Or make it a little easier to read by dereferncing it into a hash:

    my %values = %{$x->{xylanXIPGMAPLastTrapReason}->{syntax}->{values}}; foreach(keys %values) { print "$_ = $values{$_}\n"; }