return (); (the empty array) makes the code a bit more readable.
Gesendet: Montag, 12. Februar 2018 um 23:19 Uhr Von: "Bernhard Held" berny156@gmx.de An: development@lists.ipfire.org Betreff: [PATCH v2 2/4] Network::network2bin: return an empty list in case of error
'return undef;' will always return a single value 'undef' even in list context.
sub foo { return undef } if ( my @x = foo() ) { print "oops, we think we got a result"; }
config/cfgroot/network-functions.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/cfgroot/network-functions.pl b/config/cfgroot/network-functions.pl index 93bb646a6..41d36a194 100644 --- a/config/cfgroot/network-functions.pl +++ b/config/cfgroot/network-functions.pl @@ -139,7 +139,7 @@ sub network2bin($) { my $netmask_bin = &ip2bin($netmask);
if (!defined $address_bin || !defined $netmask_bin) {
return undef;
return;
}
my $network_start = $address_bin & $netmask_bin;
-- 2.16.1