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

What is the use of "stderr()"?

1014


Explain 'grep' function.

972


What are the advantages of programming in perl?

1025


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

1049


Explain lists in perl?

965


How and what are closures implemented in perl?

878


what is perl language?

925


Explain ivalue in perl?

972


How to read multi lines from a file in perl?

915


What are different data types that perl supports. Elaborate on them.

1069


What are numeric operators in perl?

947


What is “grep” function in perl?

991


Where the command line arguments are stored and if you want to read command-line arguments with Perl, how would you do that?

1084


What is the use of -n and -p options?

1037


What is the use of command “use strict”?

1013