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 does this symbol mean '->'?

946


What is the difference between localtime() and gmtime() functions?

988


What are the advantages of programming in perl?

986


How to close a file in perl?

906


For a situation in programming, how can you determine that Perl is a suitable?

854


How do you you check the return code of a command in perl?

962


There is no strict data types in perl unlike in other high level languages like Java so wouldn't that be a problem if a code in perl is to be a written by a big team of 20+ members ?"

2373


Explain a tell function in perl?

929


How can you create anonymous subroutines?

885


How can I display all array element in which each element will display on next line in perl ?

892


Write syntax to add two arrays together in perl?

890


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

907


How to remove a directory in perl?

938


Why Perl aliases are considered to be faster than references?

915


How does polymorphism work in perl? Give an example.

829