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
Explain different types of perl operators.
What does delete function do in perl?
Comment on data types and variables in perl.
How to convert strings into an array in perl?
How to open and read data files with Perl
How to deleting an existing file in perl programming?
What is the tk module?
Why -w argument is used with perl programs?
What is perl I used for?
How and what are closures implemented in perl?
In Perl, what is grep function used for?
Hi, I am a accountant. I am preparing a balance sheet but because of staff shortage and time pressures I cant complete it on time. There is lot of common data with last years which I need not retype and I can manage by editing last year’s balance sheet ? Is their any software on net where I can do this easily??
How do I sort a hash by the hash key?
Explain goto label, goto name, and goto expr?
What can be done for efficient parameter passing in perl?