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 which feature of PERL provides code reusability?
What is the use of "stderr()"?
What are the various file operations in perl. Explain with example.
what is the main function of fork() in cgi programming?
What happens when you return a reference to a private variable?
What are perl variables?
How would you ensure the re-use and maximum readability of your perl code?
There are some duplicate entries in an array and you want to remove them. How would you do that?
How we can navigate the xml documents?
Explain goto expr?
What is grep used for in perl?
How are parameters passed to subroutines in perl?
What are the purpose of close(), getc() and read() functions?
What is the use of -t?
Explain string comparison operators in perl.