Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I've made several attempts at creating a complex data structure using the following data:
I've made several attempts at creating a complex data structure using the following data:
I'm trying to use the key variable as a key in a hash, and populate the hash with an array of OID, and NAME, and finally have a value or entry in the hash for the Error statusKEY: request_1.3.6.1.2.1.2.2.1.12.27 OID: 1.3.6.1.2.1.2.2.1.11.27 NAME: ifInUcastPkts.27 OID: 1.3.6.1.2.1.2.2.1.15.27 NAME: ifInUnknownProtos.27 OID: 1.3.6.1.2.1.2.2.1.14.27 NAME: ifInErrors.27 OID: 1.3.6.1.2.1.2.2.1.13.27 NAME: ifInDiscards.27 OID: 1.3.6.1.2.1.2.2.1.18.27 NAME: ifOutNUcastPkts.27 OID: 1.3.6.1.2.1.2.2.1.17.27 NAME: ifOutUcastPkts.27 OID: 1.3.6.1.2.1.2.2.1.20.27 NAME: ifOutErrors.27 OID: 1.3.6.1.2.1.2.2.1.19.27 NAME: ifOutDiscards.27 OID: 1.3.6.1.2.1.2.2.1.10.27 NAME: ifInOctets.27 OID: 1.3.6.1.2.1.2.2.1.16.27 NAME: ifOutOctets.27 OID: 1.3.6.1.2.1.1.3.0 NAME: sysUpTime.0 OID: 1.3.6.1.2.1.2.2.1.5.27 NAME: ifSpeed.27 OID: 1.3.6.1.2.1.2.2.1.3.27 NAME: ifType.27 Error Status No error KEY: response_1.3.6.1.2.1.2.2.1.12.27 OID: 1.3.6.1.2.1.2.2.1.11.27 NAME: ifInUcastPkts.27 OID: 1.3.6.1.2.1.2.2.1.15.27 NAME: ifInUnknownProtos.27 OID: 1.3.6.1.2.1.2.2.1.14.27 NAME: ifInErrors.27 OID: 1.3.6.1.2.1.2.2.1.13.27 NAME: ifInDiscards.27 OID: 1.3.6.1.2.1.2.2.1.18.27 NAME: ifOutNUcastPkts.27 OID: 1.3.6.1.2.1.2.2.1.17.27 NAME: ifOutUcastPkts.27 OID: 1.3.6.1.2.1.2.2.1.20.27 NAME: ifOutErrors.27 OID: 1.3.6.1.2.1.2.2.1.19.27 NAME: ifOutDiscards.27 OID: 1.3.6.1.2.1.2.2.1.10.27 NAME: ifInOctets.27 OID: 1.3.6.1.2.1.2.2.1.16.27 NAME: ifOutOctets.27 OID: 1.3.6.1.2.1.1.3.0 NAME: sysUpTime.0 OID: 1.3.6.1.2.1.2.2.1.5.27 NAME: ifSpeed.27 OID: 1.3.6.1.2.1.2.2.1.3.27 NAME: ifType.27 Error Status No error
This is my code snippet below:
I have a data file that I'm extracting the information from, and the information above is what I've extracted.push(@temp, $hash) if (defined($key)); $hash = {FRAME => $key}; if ($_ =~ /Simple Network Management Protocol/) { $hash->{SNMP} = {SNMP_LIST => []}; } elsif ($_ =~ /\s*SNMP\:\s+Object\s+\=\s+(.+)/) { $oid_list->{OID} = $oid; $oid_list->{NAME} = $name; } elsif ($_ =~ /\s*SNMP\:\s*\n/) { push(@{$hash->{SNMP}->{SNMP_LIST}}, $oid_list); }
Any ideas or suggestions?
Replies are listed 'Best First'. | |
---|---|
Re: Data Structure help
by fruiture (Curate) on Mar 21, 2003 at 20:40 UTC | |
Re: Data Structure help
by BrowserUk (Patriarch) on Mar 21, 2003 at 21:11 UTC | |
Re: Data Structure help
by Enlil (Parson) on Mar 21, 2003 at 21:19 UTC |
Back to
Seekers of Perl Wisdom