Help for this page
my $string = (join(".", sort split(/\./, "Pugh.Barney.Pugh.Barney.McGr +ew.Cuthbert.Dibble.Grub"))); my @array = ($string =~ m/(\S+)\.\1/g); # Capture duplicate ... print "\n$_.$_"; } print "$string"; # Print the rest of the list
$string =~ s/(\S+)\.\1/'$1.$1'/g; # Add quotes ... my @keepers = grep defined $_, /'(.*?)'|([^.]+)/g; print map "$_\n", @keepers;