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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |