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 strftime() function in perl?
There are some duplicate entries in an array and you want to remove them. How would you do that?
How do you you check the return code of a command in perl?
How to read a single line from a file in perl?
What is cpan in perl?
Explain perl. When do you use perl for programming? What are the advantages of programming in perl?
Explain socket programming in perl?
Differentiate between c++ and perl.
What is the importance of perl warnings? How do you turn them on?
When do you use perl programming?
How to prevent file truncation in perl?
Where do we require ‘chomp’ and what does it mean?
You want to print the contents of an entire array. How would you do that?
Which has highest precedence in between list and terms? Explain?
What does redo statement do in perl?