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
Why is it hard to call this function: sub y { "because" } ?
What does read () command do?
Does Perl have reference type?
Why should I use the -w argument with my Perl programs?
How can I implement the function overloading in Perl ? I read about the operator overloading, I do not know how to implement the function overloading. Thanks in advance ?
Difference between the variables in which chomp function work ?
How will you get the count of parameters passed to a perl subroutine?
Define print() function in perl?
Explain about the applications of perl?
You want to add two arrays together. How would you do that?
How to know whether a key exists or not in perl?
What does the q{ } operator do?
List the data types that Perl can handle?
What are the steps involved in configuring a server using cgi programming?
how to connect cisco switch uisng perl script