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 access parameters passed to a subroutine in perl?

1008


There are some duplicate entries in an array and you want to remove them. How would you do that?

953


How interpreter is used in perl?

989


What is v-strings?

1141


Explain goto name?

981


What are prefix dereferencer?

992


You want to print the contents of an entire array. How would you do that?

1019


Explain substr function in perl?

1086


How can memory be managed in Perl?

1119


How can we create perl programs in unix, windows nt, macintosh and os/2 ?

927


How would you ensure the re-use and maximum readability of your perl code?

984


How to close a directory in perl?

977


Explain the default scope of variables in perl?

994


List all the features of perl programming?

949


What can be done for efficient parameter passing in perl? Explain.

1077