my %saw; my @parts = map { my $s=substr $str, $_, 3; $saw{$s}++ ? () : $s } 0..length($str)-3;