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

# Correction to my above post

$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 ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain which feature of PERL provides code reusability?

1202


What is the use of "stderr()"?

1014


What are the various file operations in perl. Explain with example.

935


what is the main function of fork() in cgi programming?

1119


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

999


What are perl variables?

917


How would you ensure the re-use and maximum readability of your perl code?

931


There are some duplicate entries in an array and you want to remove them. How would you do that?

903


How we can navigate the xml documents?

996


Explain goto expr?

866


What is grep used for in perl?

916


How are parameters passed to subroutines in perl?

935


What are the purpose of close(), getc() and read() functions?

873


What is the use of -t?

958


Explain string comparison operators in perl.

1005