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
How to start perl in interactive mode?
What is the use of –w?
What is cpan ? What are the modules coming under this?
What is the easiest way to download the contents of a URL with Perl?
What is the tk module?
What are scalars in perl?
Explain chomp, chop, cpan, tk.
What does the qx{ } operator do?
Explain 'grep' function.
How do I pass a command line argument in perl?
Define dynamic scoping.
How to copy a file in perl?
What does the q{ } operator do?
What are perl variables?
How will you open a file in read-only mode in perl?