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
How do I pass a command line argument in perl?
What do you mean by context of a subroutine?
What is a perl references?
How to close a directory in perl?
What is the peculiarity of returning values by subroutines in perl?
What is the importance of perl warnings? How do you turn them on?
What does last statement do in perl?
What is a chop() function in perl?
Explain the functioning of conditional structures in perl.
what are the two ways to get private values inside a subroutine or block?
Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.
How many ways can we express string in Perl?
Explain ivalue in perl?
How will you create a file in perl?
Can inheritance be used in perl? Explain with the help of an example.