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
Where do we require ‘chomp’ and what does it mean?
Write a program to decode the data in the form using cgi programming
Which operator in perl is used for the concatenation of two strings?
Distinguish my and local?
List the prefix dereferencer in Perl.
What are the features of perl language?
What are the different ways to run cgi?
Write an example explaining the use of symbol tables.
Explain the functioning of conditional structures in perl.
what are the strategies followed for multiple form interaction in cgi programs?
What is the difference between use and require in perl programming?
What is the closure in PERL?
Explain goto label, goto name, and goto expr?
When do you use perl programming?
Explain subroutine in perl?