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

Hi

I have retrieved the following data struture using Data::Dumper, from the SNMP::MIB::Compiler module and am having trouble constructing a method to retieve a description based on a hash key for the following data structure:

$VAR1 = bless( { 'tree' => { 'attCNMds1StatusEntry' => { '1' => 'attCN +Mds1StatusIndex', '2' => 'attCN +Mds1LineStatus' }, 'att-products' => { '9' => 'att-cnmAgent' }, 'att-2' => { '1' => 'att-products', '2' => 'att-mgmt' }, 'attCNMds1ConfigEntry' => { '1' => 'attCN +Mds1ConfigIndex', '2' => 'attCN +Mds1LineType', '3' => 'attCN +Mds1ZeroCoding', '4' => 'attCN +Mds1ErrorsMaxIntervals', '5' => 'attCN +Mds1ErrorsIntervalLen' }, 'attCNMds1ConfigTable' => { '1' => 'attCN +Mds1ConfigEntry' }, 'att-mgmt' => { '15' => 'att-cnm' }, 'attCNMds1ErrorsEntry' => { '1' => 'attCN +Mds1ErrorsIndex', '2' => 'attCN +Mds1ErrorsInterval', '3' => 'attCN +Mds1ErrorsTimeStamp', '9' => 'attCN +Mds1ESs' }, 'attCNMds1ErrorsTable' => { '1' => 'attCN +Mds1ErrorsEntry' }, 'att-cnm' => { '3' => 'att-cnm-ds1' }, 'enterprises' => { '74' => 'att-2' }, 'att-cnm-ds1' => { '1' => 'attCNMds1Confi +gTable', '2' => 'attCNMds1Statu +sTable', '3' => 'attCNMds1Error +sTable' }, 'attCNMds1StatusTable' => { '1' => 'attCN +Mds1StatusEntry' } }, 'extensions' => [ '', '.mib', '.mib.txt' ], 'filename' => 'C:\\ATT/att_ds1.mib', 'types' => { 'AttCNMds1ErrorsEntry' => { 'items' => { + 'attCNMds1SEFSs' => { + 'type' => 'Gauge' + }, + 'attCNMds1LESs' => { + 'type' => 'Gauge' + }, + 'attCNMds1ErrorsIndex' => { + 'type' => 'INTEGER' + } } +, 'type' => 'S +EQUENCE' }, 'AttCNMds1StatusEntry' => { 'items' => { + 'attCNMds1StatusIndex' => { + 'type' => 'INTEGER' + }, + 'attCNMds1LineStatus' => { + 'type' => 'INTEGER' + } } +, 'type' => 'S +EQUENCE' } }, 'repository' => 'C:\\Compiled MIBS', 'dumpext' => '.dump', 'srcpath' => [ 'C:\\ATT', 'C:\\Compiled MIBS' ], 'allow_lowcase_hstrings' => 0, 'allow_underscore' => 0, 'accept_smiv1' => 1, 'allow_keyword_any' => 1, 'accept_smiv2' => 1, 'do_imports' => 0, 'root' => { 'iso' => { 'oid' => [ 1 ] }, 'ccitt' => { 'oid' => [ 0 ] }, 'joint-iso-ccitt' => { 'oid' => [ 2 ] } }, 'make_dump' => 1, 'use_dump' => 1, 'nodes' => { 'attCNMds1StatusIndex' => { 'status' => +'mandatory', 'description +' => '"A unique value for each DS1 interface. The interface identified by a particular value of this index + is the same interface as identified by the same v +alue of an attCNMifConfigIndex object instance."', 'syntax' => +{ + 'type' => 'INTEGER' +}, 'oid' => [ ' +attCNMds1StatusEntry', ' +1' ], 'access' => +'read-only', 'type' => 'O +BJECT-TYPE' }, 'attCNMds1LineStatus' => { 'status' => ' +mandatory', 'description' + => '"This variable indicates the most Line Status
I'm trying to retrieve the description for attCNMds1StatusIndex

Any ideas?

Replies are listed 'Best First'.
Re: Data Dumper help
by Chady (Priest) on Feb 28, 2003 at 18:13 UTC
    will a $VAR1->{nodes}->{attCNMds1StatusIndex}->{description} work?
    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/
      my Dumper line looks like this:
      my $name = $mib->compile('att_ds1'); print Dumper($name);
      How do I do that using $name?
      Thanks
        $name->{nodes}->{attCNMds1StatusIndex}->{description}

        As a side note, with such complex data structures, I frequently find the output hard to read unless I tweak the indent:

        my $name = $mib->compile('att_ds1'); $Data::Dumper::Indent = 1; print Dumper($name);

        The output is then similar to the following:

        $VAR1 = { 'tree' => { 'att-products' => { '9' => 'att-cnmAgent' }, 'attCNMds1ErrorsTable' => { '1' => 'attCNMds1ErrorsEntry' }, 'attCNMds1ErrorsEntry' => { '9' => 'attCNMds1ESs', '1' => 'attCNMds1ErrorsIndex', '2' => 'attCNMds1ErrorsInterval', '3' => 'attCNMds1ErrorsTimeStamp' }, 'enterprises' => { '74' => 'att-2' }, 'attCNMds1StatusTable' => { '1' => 'attCNMds1StatusEntry' }, 'attCNMds1StatusEntry' => { '1' => 'attCNMds1StatusIndex', '2' => 'attCNMds1LineStatus' }, 'att-2' => { '1' => 'att-products', '2' => 'att-mgmt' }, ###

        Cheers,
        Ovid

        New address of my CGI Course.
        Silence is Evil (feel free to copy and distribute widely - note copyright text)

Re: Data Dumper help
by tall_man (Parson) on Feb 28, 2003 at 18:37 UTC
    Unfortunately we can't try your example Data::Dumper value because you gave us an incomplete, unclosed piece of it.