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
Explain use of ‘my’ keyword in perl?
Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.
Explain the difference between die and exit in perl?
How and what are closures implemented in perl?
How to open and read data files with Perl
Explain subroutine in perl?
How does polymorphism work in perl? Give an example.
What is the use of now constructor in perl?
How do you set environment variables in perl?
How to read file into hash array ?
What is the importance of perl warnings?
What is the importance of perl warnings? How do you turn them on?
What is a perl references?
what is CPAN?
What is the syntax used in Perl grep function?