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


Please Help Members By Posting Answers For Below Questions

Enlist the advantages of using c over perl?

523


how to extract pin_code,phone_number,year from text file using regular expressions in perl

1856


How does a “grep” function perform?

603


How to sort arrays in perl?

633


What are the different types of perl operators?

538






What is stdin in perl?

554


How to code in perl to implement the tail function in unix?

537


How do I print the entire contents of an array with Perl?

541


Explain lists ?

534


Explain perl one-liner?

523


what is the difference between java and cgi?

569


How to renaming a file in perl programming?

565


Remove the duplicate data from @array=(“perl”,”php”,”perl”,”asp”)

626


What is the function of virtual documents in cgi programs?

532


What is the different between array and hash in perl programming?

520