A non-Perl mailing list I'm on is tossing around Perl fragments. One, for determining whether a dotted quad IP address is valid, basically reads:
sub isValidIP { my $ip = shift; if ( ($a,$b,$c,$d) = $ip =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ ) { if (($a|$b|$c|$d) < 256 ) { return 1; } } return 0; }
Now, without running this code, can you see how and why this will run off the rails, and why a test case that includes "0.0.0.0", "127.0.0.1", and "255.255.255.255" won't demonstrate the problem?
So as not to give away the punchline and thus deprive people of a good puzzle, reply by posting a valid dotted-quad IP address that will demonstrate this routine failing. I'll post an explanation in 24 hours. (It doesn't have anything to do with \A and \Z.)
(Updated to correct a mistranscription, but one not related to the problem.)
In reply to Can you spot the problem? by dws
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |