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 you find the length of an array?
How does polymorphism work in perl?
What are the reasons that cookie server can’t handle multiple connections?
Distinguish my and local?
Explain what is lvalue?
In Perl, what is grep function used for?
Assuming both a local($var) and a my($var) exist, what's the difference between ${var} and ${"var"}?
What is the difference between use and require in perl programming?
Hi, I am a accountant. I am preparing a balance sheet but because of staff shortage and time pressures I cant complete it on time. There is lot of common data with last years which I need not retype and I can manage by editing last year’s balance sheet ? Is their any software on net where I can do this easily??
What can be done for efficient parameter passing in perl? Explain.
What is the purpose of goto expr statement?
Write a program to show the process of spawning a child process
Explain join function in perl?
Why aren't Perl's patterns regular expressions?
How will you declare a variable in perl?