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!
In reply to Re: Improving Efficiency
by hdb
in thread Improving Efficiency
by ccelt09
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |