Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

How can you call a subroutine and identify a subroutine?

981


Explain what is STDIN, STDOUT and STDERR?

1027


Which functions in Perl allows you to include a module file or a module and what is the difference between them?

997


You want to print the contents of an entire array. How would you do that?

946


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

978


How will you get the count of parameters passed to a perl subroutine?

942


What is grep used for in perl?

916


how to extract pin_code,phone_number,year from text file using regular expressions in perl

2228


How many ways can we express string in Perl?

953


Explain a tell function in perl?

952


Write a program that explains the symbolic table clearly.

948


What is the difference between perl array and perl hash?

1068


Perl regular expressions are greedy" what does this mean?

908


what are steps to do to lock the sony ericsson mobile with password?

2199


what is the main function of fork() in cgi programming?

1118