bug with using last inside try{}

This commit is contained in:
Oliver Gorwits
2012-12-20 20:52:47 +00:00
parent b41115f173
commit e847de5baf

View File

@@ -128,15 +128,17 @@ sub snmp_connect {
); );
my $info = undef; my $info = undef;
my $last_comm = 0;
COMMUNITY: foreach my $c (@{ setting('community_rw') || []}) { COMMUNITY: foreach my $c (@{ setting('community_rw') || []}) {
try { try {
$info = SNMP::Info->new(%snmp_args, Community => $c); $info = SNMP::Info->new(%snmp_args, Community => $c);
last COMMUNITY if ( ++$last_comm if (
$info $info
and (not defined $info->error) and (not defined $info->error)
and length $info->uptime and length $info->uptime
); );
}; };
last COMMUNITY if $last_comm;
} }
return $info; return $info;