Help for this page

Select Code to Download


  1. or download this
    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
    
  2. or download this
        $string =~ s/(\S+)\.\1/'$1.$1'/g;    # Add quotes
    
    ...
    my @keepers = grep defined $_, /'(.*?)'|([^.]+)/g;
    print map "$_\n", @keepers;