in reply to Improving Efficiency
If you set $/ to an integer, <...> reads as many characters each time. Then use tr as in BrowserUks post to count the zeroes.
use strict; use warnings; my $total_filtered = 0; open my $cgs, "<", "count.txt"; $/ = \10000; # blocksize $total_filtered += tr/0/0/ while <$cgs>; print "Found $total_filtered zeroes.\n";
UPDATE: Changed 10000 to \10000 as a reference is needed. Thanks to Anonymous monk below!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Improving Efficiency
by Anonymous Monk on Sep 01, 2013 at 18:36 UTC |