Write an expression or perl script to identify the entered
ip address is valid or not?
Answer Posted / snehal kashikar
#! /usr/bin/per
use strict;
#- Use Input
#---------------
my $ip_add = "";
#- Script start
#---------------
print"Enter the IP address\n";
$ip_add = <STDIN>;
chomp($ip_add); # Remove the last "\n" character
$ip_add=$ip_add."\."; # Append . at the end of IP address
#-------Expression to check IP address is valid or not-----#
if($ip_add =~ m/^[0-2]?[0-5]?[0-5]?\.){4}$){
print" Valid IP Address\n";
}else{
print" Invalid IP Address\n"
}
Is This Answer Correct ? | 1 Yes | 7 No |
Post New Answer View All Answers
What does last statement do in perl?
Explain string comparison operators in perl.
How does polymorphism work in perl?
Which guidelines by Perl modules must be followed?
What is the function of cgiwrap in cgi programming?
What's the difference between /^Foo/s and /^Foo/?
How will you access an element of a perl array?
What are the reasons that cookie server can’t handle multiple connections?
what is Chop & Chomp function does?
Explain goto label?
Perl regular expressions are greedy" what does this mean?
What is an interpolation in perl?
List the files in current directory sorted by size ?
What are scalars?
Mention how many ways you can express string in Perl?