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

Explain use of ‘my’ keyword in perl?

896


Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.

1015


Explain the difference between die and exit in perl?

835


How and what are closures implemented in perl?

847


How to open and read data files with Perl

1002


Explain subroutine in perl?

868


How does polymorphism work in perl? Give an example.

821


What is the use of now constructor in perl?

925


How do you set environment variables in perl?

983


How to read file into hash array ?

1031


What is the importance of perl warnings?

1064


What is the importance of perl warnings? How do you turn them on?

996


What is a perl references?

875


what is CPAN?

930


What is the syntax used in Perl grep function?

982