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 / guest

Lets assume that the text to match is present in a file
say "data.txt".
Following program will print the line containing same
starting and ending word.

open(FILE,"data.txt") or die "cannot open file : $!";

while(<FILE>) {
if($_ =~ /^(\w+)\s+.*?\1$/) {
print "the line is $_ \n";
}
}

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you replace the characters from a string and save the number of replacements?

861


Does Perl have objects? If yes, then does it force you to use objects? If no, then why?

919


Explain goto name?

879


What is the use of now constructor in perl?

929


How to concatenate strings in perl?

1001


What are the different types of perl operators?

999


What is a chop() function in perl?

969


explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.

824


What does localtime() do in perl?

960


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

3050


how to connect cisco switch uisng perl script

3809


How will you open a file in read-only mode in perl?

865


What does read () command do?

886


How can you call a subroutine and identify a subroutine?

957


Explain USE and REQUIREMENT statements?

890