From 6bca3f1426f611e4bf5ac439129498664f672eb1 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 20 Apr 2009 21:08:07 -0700 Subject: Use undef for false Standard perl convention is undefined for false rather than 0. --- scripts/vyatta-interfaces.pl | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index 60e0c84..997230d 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -86,7 +86,7 @@ exit 0; sub is_ip_configured { my ($intf, $ip) = @_; my @found = grep $ip, getIP($intf); - return $#found; + return ($#found > 0); } sub is_ip_duplicate { @@ -99,17 +99,12 @@ sub is_ip_duplicate { chomp @ipaddrs; my %ipaddrs_hash = map { $_ => 1 } @ipaddrs; - if (defined $ipaddrs_hash{$ip}) { - # - # allow dup if it's the same interface - # - if (is_ip_configured($intf, $ip)) { - return 0; - } - return 1; - } else { - return 0; - } + return unless($ipaddrs_hash{$ip}); + + # + # allow dup if it's the same interface + # + return is_ip_configured($intf, $ip); } sub touch { -- cgit v1.2.3