use strict; use warnings; my $str = q{abcdceefghfty}; for my $ch (qw(a b c d e f g)) { print qq{"$ch" Unique in "$str"\n} if $str !~ m{($ch)(?=.*\1)}; }