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


Please Help Members By Posting Answers For Below Questions

Write a script to reverse a string without using perl's built in functions?

501


What is the different between array and hash in perl programming?

513


What are the advantages of c over Perl?

522


What are scalars in perl?

534


What is the use of now constructor in perl?

522






What are the different types of perl operators?

528


What value is returned by a lone `return;’ statement?

562


What are the reasons that cookie server can’t handle multiple connections?

531


What are the steps involved in configuring a server using cgi programming?

481


Give an example of the -i and 0s option usage.

467


What are arrays in perl?

561


What is the use of -t?

542


What are the advantages of perl programming?

534


How to create a directory in perl?

522


What is the purpose of _package_ literal?

533