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

List the data types that Perl can handle?

1042


Which operator in perl is used for the concatenation of two strings?

997


What is perl dbi?

890


Explain chomp, chop, cpan, tk.

929


What is lexical variable in perl?

929


How to read a file into a hash array?

1044


How to prevent file truncation in perl?

1011


Mention the difference between die and exit in Perl?

1113


What is confess function in perl?

934


What are the purpose of close(), getc() and read() functions?

877


What is perl I used for?

950


Explain 'grep' function.

974


How do you turn on the perl warnings?

916


Explain about the applications of perl?

969


Demonstrate subroutines in perl with a simple example.

855