PBP - lexicals

This commit is contained in:
Eric Miller
2008-07-09 02:36:03 +00:00
parent 5189871fde
commit a153913d29
2 changed files with 7 additions and 9 deletions

View File

@@ -93,11 +93,10 @@ sub model {
sub root_ip { sub root_ip {
my $allied = shift; my $allied = shift;
my $ip_hash = $allied->ip_addresses(); my $ip_hash = $allied->ip_addresses();
my $ip;
my $found_ip; my $found_ip;
foreach $ip (values %{$ip_hash}) { foreach my $ip (values %{$ip_hash}) {
my $found_ip = SNMP::Info::munge_ip($ip) if (defined $ip); $found_ip = SNMP::Info::munge_ip($ip) if (defined $ip);
last; # this is only one IP address last; # this is only one IP address
} }
return $found_ip; return $found_ip;
@@ -106,10 +105,9 @@ sub root_ip {
sub mac{ sub mac{
my $allied = shift; my $allied = shift;
my $mac_hash = $allied->ip_mac(); my $mac_hash = $allied->ip_mac();
my $mac;
my $found_mac; my $found_mac;
foreach $mac (values %{$mac_hash}) { foreach my $mac (values %{$mac_hash}) {
$found_mac = SNMP::Info::munge_mac($mac); $found_mac = SNMP::Info::munge_mac($mac);
last; # this is only one MAC address last; # this is only one MAC address
} }

View File

@@ -104,12 +104,12 @@ sub model {
sub ip{ sub ip{
my $zyxel = shift; my $zyxel = shift;
my $ip_hash = $zyxel->ip_addresses(); my $ip_hash = $zyxel->ip_addresses();
my $ip; my $found_ip;
foreach $ip (keys %{$ip_hash}) { foreach my $ip (keys %{$ip_hash}) {
my $found_ip = $ip if (defined $ip and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/); $found_ip = $ip if (defined $ip and $ip =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/);
} }
return $ip; return $found_ip;
} }
1; 1;
__END__ __END__