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
What do you mean by context of a subroutine?
Explain the various characteristics of perl.
Why to use perl scripting?
What are the advantages and disadvantages of perl language?
What happens when you return a reference to a private variable?
What is the use of –w?
What are stdin, stdout and stderr?
What are the arguements we normally use for perl interpreter?
In Perl, what is grep function used for?
Explain lexical variables.
What is the purpose of redo statement?
How to close a file in perl?
what are the steps involved in reading a cgi script on the server?
What is the use of 'ne' operator?
How to deleting an existing file in perl programming?