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


Please Help Members By Posting Answers For Below Questions

Where do we require ‘chomp’ and what does it mean?

508


Write a program to decode the data in the form using cgi programming

539


Which operator in perl is used for the concatenation of two strings?

490


Distinguish my and local?

510


List the prefix dereferencer in Perl.

561






What are the features of perl language?

584


What are the different ways to run cgi?

484


Write an example explaining the use of symbol tables.

558


Explain the functioning of conditional structures in perl.

459


what are the strategies followed for multiple form interaction in cgi programs?

503


What is the difference between use and require in perl programming?

507


What is the closure in PERL?

564


Explain goto label, goto name, and goto expr?

546


When do you use perl programming?

582


Explain subroutine in perl?

482