Permalink
Browse files

* 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.
  • Loading branch information...
1 parent 38090de commit 3394657a9651accaf762c5a8796b588601c509ae Mike Heins committed Feb 9, 2014
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/Vend/Util.pm
View
@@ -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;
}

0 comments on commit 3394657

Please sign in to comment.