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 perl programming?
Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?
Is perl compiler or interpreter?
What is “grep” function in perl?
Give an example of the -i and 0s option usage.
How do I send e-mail from a Perl/CGI program on a Unix system?
How to implement a stack in Perl?
List the operator used in Perl?
In Perl, what is grep function used for?
How to close a file in perl?
What is the difference between use and require in perl?
What are the arguments and what do they mean in perl programming?
Which has the highest precedence, List or Terms? Explain?
How to connect to SQL server through Perl?
What are different data types that perl supports. Elaborate on them.