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
What does the’$_’ symbol mean?
What are different data types that perl supports. Elaborate on them.
What are the steps involved in configuring a server using cgi programming?
What is the purpose of goto expr statement?
what are the two ways to get private values inside a subroutine or block?
Remove the duplicate data from @array=(“perl”,”php”,”perl”,”asp”)
How can memory be managed in Perl?
Explain what is the scalar data and scalar variables in Perl?
Which has highest precedence in between list and terms? Explain?
What is cpan ? What are the modules coming under this?
Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.
How to find the length of an array in perl?
Explain goto expr?
What are the purpose of close(), getc() and read() functions?
How to convert arrays into a string in perl?