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
Why Perl aliases are considered to be faster than references?
what are steps to do to lock the sony ericsson mobile with password?
What does cgi program store?
How to print escaping characters inside a string in perl?
What are the various uses of perl?
How to prevent file truncation in perl?
what is the main function of fork() in cgi programming?
Give an example of the -i and 0s option usage.
How does polymorphism work in perl? Give an example.
How will you open a file in a write-only mode in perl?
What is perl I used for?
What are the various flags/arguments that can be used while executing a perl program?
What does the q{ } operator do?
Give an example of using the -n and -p option.
Explain what is the scalar data and scalar variables in Perl?