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
List the data types that Perl can handle?
Which operator in perl is used for the concatenation of two strings?
What is perl dbi?
Explain chomp, chop, cpan, tk.
What is lexical variable in perl?
How to read a file into a hash array?
How to prevent file truncation in perl?
Mention the difference between die and exit in Perl?
What is confess function in perl?
What are the purpose of close(), getc() and read() functions?
What is perl I used for?
Explain 'grep' function.
How do you turn on the perl warnings?
Explain about the applications of perl?
Demonstrate subroutines in perl with a simple example.