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
Explain the difference between declarations of 'my' and 'local' variable scope in perl?
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 ?
What is the use of -t?
What is grep used for in perl?
What is stdin in perl?
How will you open a file in read-only mode in perl?
Is there any way to add two arrays together?
How to read multi lines from a file in perl?
What is the use of now constructor in perl?
How to read a file into a hash array?
Explain ivalue?
What is the difference between single (') and double (") quote in a string in perl?
What are perl variables?
Which statement has an initialization, condition check and increment expressions in its body? Write a syntax to use that statement.
Write a program to download the contents from www.perlinterview.com/answers.php website in Perl.