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 / vipul dalwala

$infile = 'errorlog.txt';
$outfile = 'analysys.txt';

open(INFILE,$infile) || die "Unable to Open $infile-$!";
open(OUTFILE,$outfile) || die "Unable to Open $outfile-$!";

while ( <INFILE> ) {
print OUTFILE $_ if (/error/);
}

close INFILE;
close OUTFILE;

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by context of a subroutine?

1027


Explain the various characteristics of perl.

1015


Why to use perl scripting?

1067


What are the advantages and disadvantages of perl language?

968


What happens when you return a reference to a private variable?

1058


What is the use of –w?

966


What are stdin, stdout and stderr?

1208


What are the arguements we normally use for perl interpreter?

1021


In Perl, what is grep function used for?

1132


Explain lexical variables.

997


What is the purpose of redo statement?

1063


How to close a file in perl?

1007


what are the steps involved in reading a cgi script on the server?

987


What is the use of 'ne' operator?

1052


How to deleting an existing file in perl programming?

950