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

What value is returned by a lone `return;’ statement?

1059


Define say() function in perl?

966


What is perl scripting?

941


What does perl do in linux?

945


What is perl unshift array function?

1038


Explain lists ?

937


How do you set environment variables in perl?

1041


What is qq (double q)operator in perl?

1018


How can you use Perl warnings and what is the importance to use them?

974


Which has highest precedence in between list and terms? Explain?

867


What are the arguements we normally use for perl interpreter?

962


What is the usage of -i and 0s options?

987


Differentiate between use and require, my and local, for and foreach and exec and system

909


Explain socket programming in perl?

912


you are required to replace a char in a string and store the number of replacements. How would you do that?

924