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 is perl shift array function?
How to read file into hash array ?
What does Perl do if you try to exploit the execve(2) race involving setuid scripts?
Write a program to show the process of spawning a child process
Distinguish my and local?
What rules must be followed by modules in perl.
What is perl pop array function?
How will you open a file in a write-only mode in perl?
How many types of variable in perl?
How can I implement the function overloading in Perl ? I read about the operator overloading, I do not know how to implement the function overloading. Thanks in advance ?
What is the difference between perl list and perl array?
What are the reasons that cookie server can’t handle multiple connections?
explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.
What are the logical operators used for small scale operations? Explain them briefly.
What does read () command do?