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


Please Help Members By Posting Answers For Below Questions

Explain lists in perl?

558


what are steps to do to lock the sony ericsson mobile with password?

1814


Explain what is lvalue?

605


What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)

545


How do I sort a hash by the hash value?

557






Define operators used in perl?

519


what are the three groups involved in information sharing?

478


Explain socket programming in perl?

512


What is the use of '>>' in perl?

541


Why aren't Perl's patterns regular expressions?

595


How do you match one letter in the current locale?

559


What is cpan ? What are the modules coming under this?

510


We all know private variables exist in perl. But do private METHODS exist in perl ? Eg ?

2001


How to copy a file in perl?

518


Explain join function in perl?

537