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 can you replace the characters from a string and save the number of replacements?
Does Perl have objects? If yes, then does it force you to use objects? If no, then why?
Explain goto name?
What is the use of now constructor in perl?
How to concatenate strings in perl?
What are the different types of perl operators?
What is a chop() function in perl?
explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.
What does localtime() do in perl?
How to check the status of airplane mode (enable/disable) in perl for Android mobile?
how to connect cisco switch uisng perl script
How will you open a file in read-only mode in perl?
What does read () command do?
How can you call a subroutine and identify a subroutine?
Explain USE and REQUIREMENT statements?