I recently had to write code to parse files in UIEE format. Have any monks come across it before?

There isn't anything on CPAN which I could find, although there were some plaintive, unanswered cries for help out there on sites like Experts Exchange. It's a rather old-fashioned format, but still used in the book trade. Some booksellers use it to upload their inventories to Amazon, I believe.

Parsing an actual file is incredibly simple, I did it roughly like this:

$/ = "\r\n\r\n"; open( UIEEFILE, '<', '/path/to/file.txt' ); while (<UIEEFILE>) { my %book = (); foreach my $line ( split( "\r\n", $_ ) ) { my ( $key, $value ) = split( /\|/, $line, 2 ); if ( defined( $book{$key} ) ) { $book{$key} .= " $value"; } else { $book{$key} = $value; } # do something with %book } }

Though that doesn't deal with the issue of binary data, or of course error handling and so on.

Does anyone think a CPAN module would be a good idea? To me it's in a grey area where anyone halfway competent with perl would be able to knock up a script like mine in five minutes, and anyone who wasn't able to do that would have bigger problems than not having a module.

One other problem I encountered was that the UIEE files I was dealing with didn't actually follow the spec anyway, and I couldn't rely on things like field order which should indicate validity. If there's lots of invalid code out there, people will have to write their own parsers a lot of the time anyway.


In reply to Anyone for UIEE? by Cody Fendant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.