in reply to Re^2: COVID-19 data analytics, cryptography, and some things you should know
in thread COVID-19 data analytics, cryptography, and some things you should know

"The presented stings come from NGINX so don't really need any validation."

And yet, you have code that identifies the IP type by a regexp, and throws if it is not "valid."

What do you think is "far better, far faster, far lighter" about

sub _slow_is_ipv4 { shift if ref $_[0]; my $value = shift; return undef unless defined($value); my (@octets) = $value =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1, +3})$/; return undef unless (@octets == 4); foreach (@octets) { return undef if $_ < 0 || $_ > 255; return undef if $_ =~ /^0\d{1,2}$/; } return join('.', @octets); }
in Data::Validate::IP (which has a dependency on NetAddr::IP)

as compared to the code in Regexp::Common::net?

Snarky reply to AnomalousMonk's attempt to offer assistance. Downvoted. (And the reply to bliako.)


The way forward always starts with a minimal test.
  • Comment on Re^3: COVID-19 data analytics, cryptography, and some things you should know
  • Download Code

Replies are listed 'Best First'.
Re^4: COVID-19 data analytics, cryptography, and some things you should know
by AnomalousMonk (Archbishop) on Apr 05, 2020 at 22:03 UTC
    ... and throws if it is not "valid."

    ... and may accept what is not valid, e.g., '9999.9999.9999.9999' :)


    Give a man a fish:  <%-{-{-{-<