my $string = "aabbbcc"; my @array = split('',$string); my %hash = (); foreach (@array) { print "dup found!\n" if (exists($hash{$_})); $hash{$_}++; }