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
Explain the execution of a program in perl.
What are prefix dereferencer? List them.
Explain the different types of data perl can handle.
How would you ensure the re-use and maximum readability of your perl code?
Explain use of ‘my’ keyword in perl?
You want to empty an array. How would you do that?
Explain perl. What are the advantages of programming in perl?
You want to add two arrays together. How would you do that?
How to create a directory in perl?
What are arrays in perl?
If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}?
Explain splicing of arrays?
Why aren't Perl's patterns regular expressions?
Explain a tell function in perl?
How are parameters passed to subroutines in perl?