Misread :(
my %lookup = map { $_ => 1 << (ord($_) - ord('A')) } 'A'..'Z';
my $c = 'ABCHI';
my $bitmap = 0;
$bitmap |= $lookup{$_} for $c =~ /(.)/g;
print('A'..'Z', "\n");
print(scalar(reverse(sprintf("%26b", $bitmap))), "\n");
outputs
ABCDEFGHIJKLMNOPQRSTUVWXYZ
111000011
Update: Array version:
my @powers = map { 1 << $_ } 0..25;
my $c = 'ABCHI';
my $bitmap = 0;
$bitmap |= $powers[ord($_)-ord('A')] for $c =~ /(.)/g;
print('A'..'Z', "\n");
print(scalar(reverse(sprintf("%26b", $bitmap))), "\n");
Update: Replaced += with |=. It makes it tolerant to repeated letters.