<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -ws

use Parse::RecDescent;

$RD_WARN = undef;

my $parse = Parse::RecDescent-&gt;new(&lt;&lt;'EOGRAMMAR');

line: seplist[sep=&gt;','] &lt;score: @{$item[1]}&gt;
    | seplist[sep=&gt;':'] &lt;score: @{$item[1]}&gt;
    | seplist[sep=&gt;" "] &lt;score: @{$item[1]}&gt;

seplist: &lt;skip:""&gt; &lt;leftop: /[^$arg{sep}]*/ "$arg{sep}" /[^$arg{sep}]*/&gt;

EOGRAMMAR

while (&lt;DATA&gt;)
{
    chomp;
    my $res = $parse-&gt;line($_);
    print '[', join('][', @$res), "]\n";
}

__DATA__
c,o,m,m,a,s,e,p,a,r,a,t,e,d
c:o:l:o:n:s:e:p:a:r:a:t:e:d
s p a c e s e p a r a t e d
m u:l t i,s:ep ar:a,ted
m u:l,t i,s:ep ar:a,ted
m:u:l,t i,s:ep ar:a,ted
</pre></body></html>