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
How do I send e-mail from a Perl/CGI program on a Unix system?
How can arrays be tied?
What is lexical variable in perl?
You want to connect to sql server through perl. How would you do that?
what is the function that is used to identify how many characters are there in a string?
What are scalars in perl?
In CPAN module, name an instance you use.
How can memory be managed in Perl?
How to know whether a key exists or not in perl?
How to connect with sqlserver from perl and how to display database table info?
What are the advantages of programming in perl?
How can you create anonymous subroutines?
How do I replace every TAB character in a file with a comma?
How to convert strings into an array in perl?
Which functions in perl allows you to include a module file.