in reply to how to hash this
Well here is a way to read in the file in a nicer way. Change the record separator to match on semi-colon. Since you have semi-colons in your data I added the newline to the semi-colon for the record separator so it would match only the semi-colons you want. Then you can split the record on newline to get each line into an array.
I would show you the rest, but there is not enough space in this margin.
$/ = ";\n"; while(my $record = <DATA>) { my @rows = split("\n", $record); print "$rows[0]\n"; print "$rows[-2]\n"; } __DATA__ Begin Product A0001 Small gadget 5.00 0.00 0.25 0.00 No ; Tracking Inventory? /Images/gadget1.jpg ProdText\A0001.txt Begin Option Gadget Color Red Green Blue Yellow Black White End Option Begin Option Extra Attachment No Attachment <NoShow> Attachment ($5.00 extra) <+5.00> <NoTitle> End Option End Product ; Begin Product A0002 Huge Widget 25.00 2.50 20.00 0.00 Yes ; Tracking Inventory? /Images/gadget2.jpg ProdText\A0002.txt Begin Option Widget Color Red Green Blue Yellow Black White End Option Begin Option Monogramming Include monogramming <NoTitle> <Custom:0.05> No monogramming <NoTitle> End Option End Product ; Begin Product GPY01A1 GPY Angel 1 Print 8.5x11 140.00 0.00 1.00 3.00 ProdText\GPY01A1.txt SoftGoodControl: ::0:0 PriceCategory: Wholesale:114.00:114.00 Retail:114.00:114.00 Reside +ntial:114. End Product ; ##Results## Begin Product A0001 End Product Begin Product A0002 End Product Begin Product GPY01A1 End Product
|
|---|