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
You want to add two arrays together. How would you do that?
What is use of ‘->’ symbol?
How to read a single line from a file in perl?
How to read a file into a hash array?
Explain string comparison operators in perl.
What does the q{ } operator do?
What $! In perl?
How do you give functions private variables that retain their values between calls?
What is the main function of cookie server?
How many types of variable in perl?
What is the usage of -i and 0s options?
Remove the duplicate data from @array=(“perl”,”php”,”perl”,”asp”)
What are the logical operators used for small scale operations? Explain them briefly.
What rules must be followed by modules in perl.
Which operator in perl is used for the concatenation of two strings?