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
Define print() function in perl?
Define say() function in perl?
What are the options that can be used to avoid logic errors in perl?
Explain perl. What are the advantages of programming in perl?
How does a “grep” function perform?
Explain chop?
What happens when you return a reference to a private variable?
What is it meants by '$_'?
What does last statement do in perl?
Explain perl. When do you use perl for programming?
What is a perl references?
List the data types that Perl can handle?
Write a program to decode the data in the form using cgi programming
Explain goto name?
How to read a directory in perl?