sub bin2num($) { my $n = 0; ($n <<= 1) += $_ foreach split(//,shift); $n; }