UPDATE: totally rewrote the thing under license from TIMTOWTDI. Instead of doing things in decimal, I convert the mask to the 32-bit string, then look to see if there is a zero followed by a one. Takes care of most identified concerns.
UPDATE 1: okay ... took out the Socket requirement ... THX to whomever pointed this out ...
UPDATE 2: Threw the $mask var back in ... can't remember why I started playing w/ that
sub validateMask { return # return undef if it's not com +plete unless $_[0] =~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; my $mask = unpack ( "B32", pack( "C4", split ( /\./, $_[0] ) ) ); return # return undef if we find an i +nvalid if $mask =~ /01/; # mask ( a zero followed by a +one ) return 1; # return 1 if everything is ok +ay }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: validateMask (regex tweak, 30bit mask, CPAN modules)
by ybiC (Prior) on May 09, 2001 at 02:02 UTC | |
by idnopheq (Chaplain) on May 09, 2001 at 18:51 UTC | |
|
Re: validateMask
by Petruchio (Vicar) on May 13, 2001 at 07:33 UTC | |
|
Re: validateMask
by no_slogan (Deacon) on May 09, 2001 at 02:59 UTC | |
by idnopheq (Chaplain) on May 09, 2001 at 03:41 UTC |