That really scores...

what about some bin:

@ip = split (/\./);
foreach $part (@ip) {
        $binpart = dec2bin($part) # Reports Error if not dec numeric
        unless ($binpart =~ /^\d{8}$/ ) { # if not exactly 8 bits
                print "not an IP";
        }
}

don´t know if this works

unless ((dec2bin($part)) =~ /^\d{8}$/ ){
        print "not an ip";
}

I used weeks ago:
/^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|
2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$/

> -----Ursprüngliche Nachricht-----
> Von: Samy Kamkar [mailto:[EMAIL PROTECTED]]
> Gesendet am: Dienstag, 20. August 2002 15:02
> An: Angerstein
> Cc: [EMAIL PROTECTED]
> Betreff: Re: AW: how to make a regex for a ip address
>
> /^(?:0*(?:2(?:[0-4]\d|5[0-5])|1?\d{1,2})(?:\.|$)){4}/
>
> -Samy
>
> Angerstein wrote:
>
> > What about:
> > /\d?\d?\d\.\d?\d?\d\.\d?\d?\d\.\d?\d?\d\/
> >
> > or
> >
> > @ip = split (/\./);
> > foreach $part (@ip) {
> >     if ( $part > 255 && $part =~ /\d?\d?\d\/ ) {
> >             die "That´s not an IP";
> >     }
> > }
> >
> >
> >>-----Ursprüngliche Nachricht-----
> >>Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]Im Auftrag von
> >>zentara
> >>Gesendet am: Dienstag, 20. August 2002 14:50
> >>An: [EMAIL PROTECTED]
> >>Betreff: Re: how to make a regex for a ip address
> >>
> >>On Mon, 19 Aug 2002 12:07:21 -0700, [EMAIL PROTECTED] (Root) wrote:
> >>
> >>>for a one liner:
> >>>
> >>>$_ = '12.34.56.78';
> >>>map {$_ < 256} /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/g || warn("not
> >>>
> >>valid ip: $_\n");
> >>
> >>I tried this with $_ = '1234.2345.56.78';  and received no warning.
> >>That's not good.
> >>
> >>
> >>
> >>--
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> >
>
>
> --
> Samy Kamkar -- cp5 -- [EMAIL PROTECTED]
> LucidX.com / LA.pm.org / code.LucidX.com
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to