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 / prabhakaran m
## Go to that Directory
my $file_output = "output";
open(OUTFILEHANDLE,">$file_output") || die "Unable to open
the file : $file_output";
foreach my $input_file (`ls -1`) {
open(INFILEHANDLE,"$input_file") || die "Unable to
open the file : $input_file";
while (<INFILEHANDLE>) {
print OUTFILEHANDLE $_ if (/print header/);
}
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What is the syntax used in Perl grep function?
How can the user execute a long command repeatedly without typing it again and again?
How to read from a pipeline with Perl
Can inheritance be used in perl?
What is the difference between single (') and double (") quote in a string in perl?
Explain chop?
What is cpan in perl?
What is chomp() operator/function?
How do you match one letter in the current locale?
Explain the meaning of closure in perl.
What is the difference between exec and system?
what is the difference between java and cgi?
What is automatic error handling in perl?
How many types of variable in perl?
What can be done for efficient parameter passing in perl? Explain.