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 Perl one liner?

858


What is the purpose of “_file_ literal” and “_line_ literal” in perl?

865


Why to use perl scripting?

929


What are the different types of perl operators?

974


Explain perl. What are the advantages of programming in perl?

967


What are the options that can be used to avoid logic errors in perl?

896


How to start perl in interactive mode?

972


Explain the meaning of perl one-liner?

998


If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}?

933


Give an example of using the -n and -p option.

942


How to connect to SQL server through Perl?

979


What does undef function in perl?

879


Show the use of sockets for the server and client side of a conversation?

825


How do I read command-line arguments with Perl?

963


What is the difference between use and require in perl?

806