sub validator { my $string = shift; my @chunks = map { [ split '' ] } $string =~ /(?=(...))./g; @$_ = sort @$_ for @chunks; my %count; for (map { join '', @$_ } @chunks) { return if $count{$_}++; } return 1; }