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

Define print() function in perl?

553


Define say() function in perl?

543


What are the options that can be used to avoid logic errors in perl?

518


Explain perl. What are the advantages of programming in perl?

565


How does a “grep” function perform?

599






Explain chop?

536


What happens when you return a reference to a private variable?

532


What is it meants by '$_'?

540


What does last statement do in perl?

527


Explain perl. When do you use perl for programming?

448


What is a perl references?

524


List the data types that Perl can handle?

575


Write a program to decode the data in the form using cgi programming

545


Explain goto name?

523


How to read a directory in perl?

534