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
What is the use of "stderr()"?
Explain 'grep' function.
What are the advantages of programming in perl?
What value is returned by a lone `return;’ statement?
Explain lists in perl?
How and what are closures implemented in perl?
what is perl language?
Explain ivalue in perl?
How to read multi lines from a file in perl?
What are different data types that perl supports. Elaborate on them.
What are numeric operators in perl?
What is “grep” function in perl?
Where the command line arguments are stored and if you want to read command-line arguments with Perl, how would you do that?
What is the use of -n and -p options?
What is the use of command “use strict”?