in reply to RE: Re: Need to build attribute parser
in thread Need to build attribute parser
The problem is probably that some lines include commas, so the [^,]* stops at the first comma instead of the last one
so you need to replace:
if( m/^\s*-([\w-]+) \s*:\s*([^,]*),?$/) { ($field, $val)= ($1, $2); } elsif( m/^\s*([^,]*),?$/) { $val= $1; }
by
if( m/^\s*-([\w-]+) \s*:\s*(.*)$/) { ($field, $val)= ($1, $2); } elsif( m/^\s*(.*)?$/) { $val= $1; } $val=~s/,$//;
|
|---|