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

Differentiate between arrays and list in perl.

1033


Explain the functioning of conditional structures in perl.

1002


Why we use CGI?

2592


Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.

1105


Explain goto label?

975


What is confess function in perl?

998


What is a chomp() function in perl?

1106


Can inheritance be used in perl? Explain with the help of an example.

1052


What is subroutine in perl?

992


How to know whether a key exists or not in perl?

1022


What is the difference between perl array and perl hash?

1175


Why aren't Perl's patterns regular expressions?

1250


How to read a file into a hash array?

1095


There are two types of eval statements i.e. Eval expr and eval block. Explain them.

1100


You want to download the contents of a url with perl. How would you do that?

928