http://www.perlmonks.org?node_id=57515


in reply to Dynamic array names

Thanks to everyone that helped me get aroudn the pointer to arrays and hashes of array references and all that mutha jazz. I post my result here. Thsi is my first real foray into arrays and as such I hope is received kindly. Thanks to masem for that lovely snippet just above me. I am going to need a glass fo hogfat to wash that down my mental gullet, so to speak.
#!/usr/bin/perl use SNMP_util; $nameOID = ".1.3.6.1.4.1.2021.2.1.2"; @addOID = qw(.1.3.6.1.4.1.2021.2.1.3 .1.3.6.1.4.1.2021.2.1.4 .1.3.6.1. +4.1.2021.2.1.5 .1.3.6.1.4.1.2021.2.1.101); $IP = "127.0.0.1"; (@tempNameArray) = &snmpwalk($IP,$nameOID); foreach $a (@tempNameArray) { ($throw, $name) = split(/:/,$a,2); push(@arrayNames, $name); } $control = 0; foreach $i (@arrayNames) { foreach $j (@addOID) { (@breakMe) = &snmpwalk($IP,$j); ($throw, $value) = split(/:/,$breakMe[$control +],2); $resultHash{$i} .= $value.","; } $control++; } foreach $key (keys %resultHash) { ($svcMax, $svcMin, $svcActual, $svcErr) = split(/,/,$resultHas +h{$key}); print "-----------------------\n",$key, " values are:\n"; print "Maximum Services: ", $svcMax, "\n"; print "Minimum Services: ", $svcMin, "\n"; print "Actual Services Running: ", $svcActual, "\n"; print "Error Message: ", $svcErr, "\n"; }