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

In reply to Re: how to hash this by DeaconBlues
in thread how to hash this by malaga

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.