in reply to Divide a list of string into substrings

I don't understand all the business about scoring, but at least this gets the expected fields for the given input strings. Perhaps you can use it as a point of departure to achieve your true goals.

c:\@Work\Perl\monks>perl -wMstrict -le "use Test::More 'no_plan'; use Test::NoWarnings; ;; use Data::Dump qw(dd); ;; use List::MoreUtils qw(uniq); ;; my @list = ( 'set abcde-efghi 12345', 'set abcde-ijkl 12345', 'clr abcde-efghi+123', 'clr abcde-ijkl 12345', ); ;; my @expected_substrings = ( 'set', 'clr', ' abcde-', 'efghi', 'ijkl', ' 12345', '+123', ); ;; my $rx_fld1 = qr{ [[:alpha:]]{2,} }xms; my $rx_fld2 = qr{ \s [[:alpha:]]{2,} - }xms; my $rx_fld3 = qr{ [[:alpha:]]{3,} }xms; my $rx_fld4 = qr{ [\s+] [[:digit:]]{2,} }xms; ;; my (@flds1, @flds2, @flds3, @flds4); for my $str (@list) { my $parsed = my ($fld1, $fld2, $fld3, $fld4) = $str =~ m{ \A ($rx_fld1) ($rx_fld2) ($rx_fld3) ($rx_fld4) \z }xms; die qq{'$str' parse failed} unless $parsed; ;; push @flds1, $fld1; push @flds2, $fld2; push @flds3, $fld3; push @flds4, $fld4; } ;; my @got_substrings = uniq @flds1, @flds2, @flds3, @flds4; dd \@got_substrings; ;; is_deeply \@got_substrings, \@expected_substrings, 'extracted list ok'; " ["set", "clr", " abcde-", "efghi", "ijkl", " 12345", "+123"] ok 1 - extracted list ok ok 2 - no warnings 1..2
Note: uniq is also in List::Util in up-to-date versions of Perl; I'm testing under version 5.8.9.

Update: It occurs to me that the uniq-ifying step should be done on each sub-set individually before the sub-sets are combined together. This could be done with a
    my @got_substrings = map { uniq @$_ } \(@flds1, @flds2, @flds3, @flds4);
statement. The output list produced is the same.

Give a man a fish:  <%-{-{-{-<