my $text = '0101010101'; my %hash; @hash{ split '', $text } = 1; print scalar keys %hash, "\n";