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
Explain goto label?
Explain tk?
What does -> symbol indicates in Perl?
Explain the functioning of conditional structures in perl.
What is the use of -t?
What are the steps involved in configuring a server using cgi programming?
What happens when you return a reference to a private variable?
What is the difference between use and require in perl programming?
Explain the arguments for perl interpreter.
What are the two ways to get private values inside a subroutine?
How to print escaping characters inside a string in perl?
What is confess function in perl?
How will you create a file in perl?
How to replace perl array elements?
What is the function of cgiwrap in cgi programming?