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 will you access an element of a perl array?

945


What does undef function in perl?

953


What is the different between array and hash in perl programming?

935


What is lexical variable in perl?

943


Define operators used in perl?

942


Write a program to show the process of spawning a child process

860


List the files in current directory sorted by size ?

987


Differentiate between arrays and list in perl.

993


Explain the difference between "my" and "local" variable scope declarations. ?

1074


What are the steps involved when the cgi program starts running?

920


Why to use perl?

955


What $! In perl?

966


Define dynamic scoping.

897


Explain lists and ivalue?

955


What is the difference between perl list and perl array?

867