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 are scalar data and scalar variables?
Explain what is lvalue?
You want to download the contents of a url with perl. How would you do that?
Why aren't Perl's patterns regular expressions?
How many types of primary data structures in Perl and what do they mean?
Explain substr function in perl?
What does 'do' statement do in perl?
What is perl unshift array function?
How do you find the length of an array?
In CPAN module, name an instance you use.
What is stdin in perl?
What is an interpolation in perl?
What are the options that can be used to avoid logic errors in perl?
What is automatic error handling in perl?
Is there any way to add two arrays together?