Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

How to start perl in interactive mode?

1041


What is the use of –w?

932


What is cpan ? What are the modules coming under this?

921


What is the easiest way to download the contents of a URL with Perl?

950


What is the tk module?

952


What are scalars in perl?

954


Explain chomp, chop, cpan, tk.

929


What does the qx{ } operator do?

906


Explain 'grep' function.

974


How do I pass a command line argument in perl?

969


Define dynamic scoping.

883


How to copy a file in perl?

978


What does the q{ } operator do?

899


What are perl variables?

921


How will you open a file in read-only mode in perl?

895