Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is the syntax used in Perl grep function?

1046


How can the user execute a long command repeatedly without typing it again and again?

937


How to read from a pipeline with Perl

1049


Can inheritance be used in perl?

1001


What is the difference between single (') and double (") quote in a string in perl?

1016


Explain chop?

923


What is cpan in perl?

958


What is chomp() operator/function?

1073


How do you match one letter in the current locale?

1022


Explain the meaning of closure in perl.

1033


What is the difference between exec and system?

1094


what is the difference between java and cgi?

1083


What is automatic error handling in perl?

1060


How many types of variable in perl?

1079


What can be done for efficient parameter passing in perl? Explain.

1043