Write a simple regular expression to match an IP address,
e-mail address, city-state-zipcode combination.
Answer Posted / jayakumar.b
sub validate_ip {
my $ip = shift;
if ( $ip =~ m/^([1-9]|1[0-9]{1,2}|2[0-4]\d|25[0-5])(\.([0-9]|1[0-9]{1,2}|2[0-4]\d|25[0-5])){3}$/ ) {
return 0;
} else {
return 1;
}
}
validate_ip("127.0.0.1");
| Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
What is the difference between use and require in perl?
Explain use of ‘my’ keyword in perl?
Define perl scripting?
What is boolean context?
Write an example explaining the use of symbol tables.
How to open and read data files with Perl
How do you turn on the perl warnings?
What are the features of perl language?
What is hash?
Explain the functioning of conditional structures in perl.
Explain chomp, chop, cpan, tk.
How do you match one letter in the current locale?
What is cpan ? What are the modules coming under this?
What does this symbol mean '->'?
“The methods defined in the parent class will always override the methods defined in the base class”. What does this statement means?