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
Explain grooving and shortening of arrays?
How can memory be managed in Perl?
List the operator used in Perl?
What package you use to create a windows services?
What does Perl do if you try to exploit the execve(2) race involving setuid scripts?
In Perl, what is grep function used for?
Explain ivalue?
What value is returned by a lone `return;’ statement?
Demonstrate subroutines in perl with a simple example.
Why does Perl not have overloaded functions?
What are perl variables?
What is the use of strict?
what are the strategies followed for multiple form interaction in cgi programs?
Explain arrays in perl.
Can inheritance be used in perl? Explain with the help of an example.