my $sentence = "I am going to go feed the the cat.";

if $sentence ~~ / (\w+) \h+ $0 / {
    say "Duplicate word '$0 $0' found at position $/.from().";
}