my $buf; my @out = (); while ( length( $bigstring )) { $buf = ''; $buf = $buf . chop $bigstring for (0..2); for (0..3) { push @out, ($buf & 64); # update: Perl didn't accept this bit op $buf >>= 6; # but is happy with this one } }