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 socket programming in perl?

854


Give an example of using the -n and -p option.

941


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

887


Create a function that is only available inside the scope where it is defined ?

941


In Perl, there are some arguments that are used frequently. What are that arguments and what do they mean?

856


What is the main function of cookie server?

999


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

838


What are the different instances used in cgi overhead?

924


Which guidelines by Perl modules must be followed?

961


What is perl? What is the basic command to print a string in perl?

824


Explain about typeglobs?

874


Explain what is STDIN, STDOUT and STDERR?

967


What is it meants by '$_'?

857


In CPAN module, name an instance you use.

905


How do I do fill_in_the_blank for each file in a directory?

908