in reply to Re: Need to build attribute parser
in thread Need to build attribute parser

OK... So I tried the above and that was great but in my rush to post. I didn't accurately represent the sample data. So the script is dying on certain unparsable lines. (See below.)

Any advice? Lines like this also exist!
-frame-print-settings-path : !{dazel-install-directory}!/lib/fm_pr +int_settings.doc -font-directories : !{dazel-install-directory}!/lib/FONTS +/Soft_Horizons -ps-init-directories : !{dazel-install-directory}!/lib/PS -footer-text-default : Printed by DAZEL, Page !{page-number}!, !{started-printing-time}! -header-footer-font : Helvetica-Bold -header-footer-font-size : 12 -ps-prologue-file : ps_prologue.psc, hp8500dn.ps -physical-device-type : ps-printer -output-document-format-default: ps -output-bin-xlate : {face-down, 1}, {top, 1}, {face-up, 2}, {left, 2} -input-trays-xlate : {tray1, 0}, {tray2, 2}, {tray3, 3}, {tray4, 4}, {large-capacity, 4} -ps-printer-echoes-eof : true

Replies are listed 'Best First'.
RE: RE: Re: Need to build attribute parser
by mirod (Canon) on Sep 29, 2000 at 00:51 UTC

    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/,$//;