in reply to Parsing SNMP output
Yes, you want a hash of arrays.dynamically named subarrays based upon the 1st column's count
my %snmp_who; while(<>) { my ( $id, $type, $value ) = split " ", $_, 3; # !FIXME! push @{ $snmp_who{$id} }, $value; } print "@{ $snmp_who{$_} }\n" for keys %snmp_who;
You should at least read perldoc perlreftut. perldoc perldsc and perldoc perllol also provide helpful introductions to the same topics.
Note that I don't know the exact specification of the SNMP reply format, so my split solution is likely broken.
Come to think of it there's Net::SNMP on CPAN, so unless you have a really good reason not to (and there are very very few of those), you should use that instead.
Makeshifts last the longest.
|
|---|