And in addition to your other good answers, you also have a scoping issue...
my @values = values (%$result); foreach my $key (@values) { print "$key\n"; my $status = $key; print "$status\n"; } .... #(testing status)
You'll find that even if you change the if test ( if( $status == $condition ) ) - you're not testing the $status you think you are. Turning on warnings and strict would help:
#!/usr/bin/perl use strict; use warnings; my $result = { 1 => 2, 3 => 4 }; my @values = values (%$result); foreach my $key (@values) { print "$key\n"; my $status = $key; print "$status\n"; } print "status: $status\n";
Output:
$ perl benco.pl Global symbol "$status" requires explicit package name at benco.pl lin +e 15. Execution of benco.pl aborted due to compilation errors.
By declaring my $status inside your earlier foreach loop, you don't have access to it outside your foreach loop - once you exit that loop, the $status you have so carefully stored simply goes away :-)
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)
In reply to Re: Multiple conditions matching when pulling OID value with Net::SNMP
by chargrill
in thread Multiple conditions matching when pulling OID value with Net::SNMP
by Bennco99
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |