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

# Correction to my above post

$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 ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain perl.

552


What are prefix dereferencer?

506


Can we load binary extension dynamically?

577


Why -w argument is used with perl programs?

554


What is the difference between perl array and perl hash?

519






Explain use of ‘my’ keyword in perl?

573


List the operator used in Perl?

540


How do find the length of an array?

518


How can you use Perl warnings and what is the importance to use them?

536


how to connect cisco switch uisng perl script

3379


Can inheritance be used in perl?

552


Explain what is lvalue?

601


How to connect with sqlserver from perl and how to display database table info?

531


What is the difference between use and require in perl programming?

513


What is the function of cgiwrap in cgi programming?

492