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
Which of these is a difference between Perl and C++ ?
How to prevent file truncation in perl?
You want to read command-line arguements with perl. How would you do that?
How to deleting an existing file in perl programming?
What syntax is used for grep() function?
How to remove a directory in perl?
How will you create a file in perl?
How do I send e-mail from a Perl/CGI program on a Unix system?
Explain arrays in perl.
How to know whether a key exists or not in perl?
What are the advantages of programming in perl?
Which guidelines by Perl modules must be followed?
Explain '->' in perl?
Give an example of the -i and 0s option usage.
Explain a tell function in perl?