Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate IP address

Status
Not open for further replies.

rvBasic

Programmer
Oct 22, 2000
414
BE
A search on the fora returned me amongst other this sub:

Code:
sub is_ipv4 {
    my $self = shift if ref($_[0]); 
    my $value = shift;
 
    return unless defined($value);
 
    my(@octets) = $value =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
    return unless (@octets == 4);
    foreach (@octets) {
        return unless ($_ >= 0 && $_ <= 255);
    }
 
    return join('.', @octets);
}

Can somebody explain what the first statement is used for? I see no further use of $self in this sub?


_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
I don't know the context from which you took this sub. I suppose it can be used with a object reference as first paramter and a value as the second OR with only a value. In the first case, the object reference is simply ignored.
HTH,
yai
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top