[interchange] * Fix non-working (in 5.8.x perl) is_ipv4() routine. (split '.' doesn't

Mike Heins interchange-cvs at icdevgroup.org
Sun Feb 9 13:51:39 UTC 2014


commit 3394657a9651accaf762c5a8796b588601c509ae
Author: Mike Heins <heins at icdevgroup.com>
Date:   Sun Feb 9 08:49:17 2014 -0500

    * Fix non-working (in 5.8.x perl) is_ipv4() routine. (split '.' doesn't
      do what you might think it does.)
    
    * Have concerns about efficiency of this and wisdom of using
      this routine for a string which is not being used as an IP address,
      but not suggesting change. I guess CPUs are getting faster.

 lib/Vend/Util.pm |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/lib/Vend/Util.pm b/lib/Vend/Util.pm
index a8a2683..2152bad 100644
--- a/lib/Vend/Util.pm
+++ b/lib/Vend/Util.pm
@@ -880,11 +880,11 @@ sub is_hash {
 # Verify that passed string is a valid IPv4 address.
 sub is_ipv4 {
     my $addr = shift or return;
-    my @segs = split '.', $addr;
+    my @segs = split /\./, $addr;
     return unless @segs == 4;
     foreach (@segs) {
-	return unless /^\d{1,3}$/ && !/^0\d/;
-	return unless $_ <= 255;
+		return unless /^\d{1,3}$/ && !/^0\d/;
+		return unless $_ <= 255;
     }
     return 1;
 }



More information about the interchange-cvs mailing list