http://www.perlmonks.org?node_id=1209090

sabas has asked for the wisdom of the Perl Monks concerning the following question:

I have a large xml file that has 946,388,628 lines. I created a simple .pl script to read and count the lines but it took so long just to finish reading the whole file without any logic added just read each line and count it. Is there a way I can speed up the process in PERL (I am new in PERL). I am planning to search for a certain "old string" in each line and replace with the "new string".

$ARGV[0] or die "ERROR: No file for 114 lines"; $ARGV[1] or die "ERROR: No file for 114 lines"; open my $bigfile,"<",$ARGV[0] or die "ERROR: COuld not open big file $ +ARGV[0]:$!"; open my $outfile,">",$ARGV[1] or die "Error: Could not open output fil +e $ARGV[0]:$!"; $datestring = localtime(); print $outfile "Processing started...at $datestring\n"; print "Processing started...at $datestring\n"; my $lctr = 0; while (my $line = <$bigfile>) { chomp $line; $lctr++; } $datestring = localtime(); print $outfile "Processing Ended...at $datestring\n"; print $outfile "Total Lines read in $ARGV[0] = $lctr"; close $bigfile; close $outfile;