In this case you don't want to read the record line-by-line. You want to read it record-by-record, where each record is delineated by a "Begin Product/End Product" pair. This is what I'd do in a case like this: (untested code ahead)
As far as the folding, spindling, and mutilating goes you're on your own. Your file format is so irregular that you'll have to meticulously parse it bit by bit. Something like "split" only works on regular formatted records, which you don't have here. You may end up doing additional regex matches for "Begin Option/End Option" within each record. It ain't pretty; the more irregular your data is the uglier the code is going to be extracting it.open (FILE, $lfilename) or &dienice; $/ = undef; # Slurp mode $file = (<FILE>); # Grab the whole file into $file while ($file =~ m/Begin Product(.*?)End Product/gs) { my $record = $1; # Now $record contains the entire contents of exactly one # record from your file. You can now fold, spindle, and # otherwise mutilate $record to pull out the various # and sundry pieces for each record. }
Gary Blackburn
Trained Killer
Update: Corrected a stupid error. This is why I shouldn't code this late at night. :-P
In reply to Re: how to hash this
by Trimbach
in thread how to hash this
by malaga
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |