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

How to copy a file in perl?

922


Explain about the applications of perl?

918


Explain what is the scalar data and scalar variables in Perl?

901


How to read file into hash array ?

1026


How to close a file in perl?

895


Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?

927


What is the use of -t?

915


Mention what is cpan?

965


What are the advantages of programming in perl?

964


How we can navigate the xml documents?

941


Explain the arguments for perl interpreter.

1154


Who created perl?

881


What package you use to create a windows services?

837


How to renaming a file in perl programming?

984


What are the features of perl language?

1029