i have a folder called 'error' and in that, i have error log
files which are generated by the build,
now i want to findout the string 'error' from each log
file and that error has to be copied into the another file
called 'analysis'.
how do you do this in perl?
Answer Posted / vipul dalwala
$infile = 'errorlog.txt';
$outfile = 'analysys.txt';
open(INFILE,$infile) || die "Unable to Open $infile-$!";
open(OUTFILE,$outfile) || die "Unable to Open $outfile-$!";
while ( <INFILE> ) {
print OUTFILE $_ if (/error/);
}
close INFILE;
close OUTFILE;
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
What are the different string manipulation operators in perl?
What are the different ways to run cgi?
What is the function of cgiwrap in cgi programming?
What are the reasons that cookie server can’t handle multiple connections?
How do I send e-mail from a Perl/CGI program on a Unix system?
What is perl push array function?
Explain perl. When do you use perl for programming?
What is perl unshift array function?
Explain perl.
Which statement has an initialization, condition check and increment expressions in its body? Write a syntax to use that statement.
Explain cpan?
What is q (single q) operator in perl?
What are the options that can be used to avoid logic errors in perl?
How can you call a subroutine and identify a subroutine?
How to find the length of an array in perl?