write a perl script to find whether a given line of text is
starting and ending with same word or not ???
Answer Posted / vipul dalwala
Above solution ($_ =~ /^(\w+)\s+.*?\1$/) does not work for
string like "vipul on allinterview.com onvipul";
I would suggest :
if( $_ =~ /^([^\s]+)(\s.*?)*\s\1$/ ) {
print "the line is $_ \n";
}
| Is This Answer Correct ? | 3 Yes | 3 No |
Post New Answer View All Answers
What value is returned by a lone `return;’ statement?
Define say() function in perl?
What is perl scripting?
What does perl do in linux?
What is perl unshift array function?
Explain lists ?
How do you set environment variables in perl?
What is qq (double q)operator in perl?
How can you use Perl warnings and what is the importance to use them?
Which has highest precedence in between list and terms? Explain?
What are the arguements we normally use for perl interpreter?
What is the usage of -i and 0s options?
Differentiate between use and require, my and local, for and foreach and exec and system
Explain socket programming in perl?
you are required to replace a char in a string and store the number of replacements. How would you do that?