#!/usr/bin/perl -wl use strict; my $count = 0; my $long; open FILE, "file.txt" or die "Couldn't open file: $!\n"; binmode FILE; while (read FILE, $long, 4) { $count += unpack'%32b*', $long; } print $count; __END__