http://qs321.pair.com?node_id=11121740


in reply to regex, find words that occur more than once.

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11121725 use warnings; use List::Util qw( uniq ); my $text = "and him him lad has him done and john has has"; print "$_\n" for uniq $text =~ /(\b\w+\b)(?=.*?\b\1\b)/g;

Outputs:

and him has