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
How will you access an element of a perl array?
What does undef function in perl?
What is the different between array and hash in perl programming?
What is lexical variable in perl?
Define operators used in perl?
Write a program to show the process of spawning a child process
List the files in current directory sorted by size ?
Differentiate between arrays and list in perl.
Explain the difference between "my" and "local" variable scope declarations. ?
What are the steps involved when the cgi program starts running?
Why to use perl?
What $! In perl?
Define dynamic scoping.
Explain lists and ivalue?
What is the difference between perl list and perl array?