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
Define operators used in perl?
What is boolean context?
how to get back up from private character editor which is saved in the format of .udf
What does -> symbol indicates in Perl?
Write a script to reverse a string without using perl's built in functions?
What is perl? What is the basic command to print a string in perl?
Explain 'grep' function.
What are arrays in perl?
How to create a directory in perl?
What does localtime() do in perl?
What are the various perl data types based on the context?
What is the use of strict?
Write syntax to add two arrays together in perl?
“The methods defined in the parent class will always override the methods defined in the base class”. What does this statement means?
Explain perl one-liner?