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 Perl one liner?
What is the purpose of “_file_ literal” and “_line_ literal” in perl?
Why to use perl scripting?
What are the different types of perl operators?
Explain perl. What are the advantages of programming in perl?
What are the options that can be used to avoid logic errors in perl?
How to start perl in interactive mode?
Explain the meaning of perl one-liner?
If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}?
Give an example of using the -n and -p option.
How to connect to SQL server through Perl?
What does undef function in perl?
Show the use of sockets for the server and client side of a conversation?
How do I read command-line arguments with Perl?
What is the difference between use and require in perl?