print my $out = join '', map {substr unpack('B8'), 1} split //, '4B'; #### print my $out = join '', map {sprintf '%07b', ord} split //, '4B';