Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write an expression or perl script to identify the entered
ip address is valid or not?

Answer Posted / savitha sridhar

print "Enter an ip address: ";
$ans=<stdin>;
chomp($ans);
if ($ans =~ m/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
{
if (($1<=255) && ($2<=255) && ($3<=255) &&
($4<=255))
{
print "An IP Address";
}
else
{
print "Not an IP Address";
}
}
else
{
print "Not an IP Address";
}

Is This Answer Correct ?    12 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain grooving and shortening of arrays?

1030


How can memory be managed in Perl?

974


List the operator used in Perl?

922


What package you use to create a windows services?

832


What does Perl do if you try to exploit the execve(2) race involving setuid scripts?

892


In Perl, what is grep function used for?

1012


Explain ivalue?

937


What value is returned by a lone `return;’ statement?

1006


Demonstrate subroutines in perl with a simple example.

819


Why does Perl not have overloaded functions?

974


What are perl variables?

877


What is the use of strict?

866


what are the strategies followed for multiple form interaction in cgi programs?

882


Explain arrays in perl.

882


Can inheritance be used in perl? Explain with the help of an example.

904