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 package you use to create a windows services?

832


Explain which feature of PERL provides code reusability?

1155


Which of these is a difference between Perl and C++ ?

966


What is the difference between localtime() and gmtime() functions?

950


Explain cpan?

910


How do you you check the return code of a command in perl?

939


What does file test operators do in perl?

862


Why -w argument is used with perl programs?

915


Why to use perl?

889


What is stdin in perl?

916


What is the purpose of “_file_ literal” and “_line_ literal” in perl?

868


Mention what is cpan?

952


What are the logical operators used for small scale operations?

907


Explain the various characteristics of perl.

899


How to check the status of airplane mode (enable/disable) in perl for Android mobile?

3035