In that case you need to be smarter about recognizing records. There seems to be a line number associated with each line of a record so you can notice when the line number resets:

use warnings; use strict; use Data::Dump::Streamer; my %records; my @lines; while (! eof (DATA) or @lines) { my $line = <DATA>; $line ||= ''; # Avoid a bunch of defined tests chomp $line; next unless $line =~ /^([\s\d]\d)/ or @lines; if (! defined $1 or $1 <= @lines) { # Start of new record (or last record) - save previous my $id = substr $lines[0], 9, 5; $records{$id} = [@lines]; @lines = (); } push @lines, $line if length $line; } Dump (\%records); __DATA__ 10101ABC000019101L0001374686047S30339 GA &DOE C080229CR7 7 +00244 0000001 000000000 2 CR7 000 060714Q + Y 0000000000 000 3 00030339 3JO +HN DOE 36 423 MAIN STREET ATLANTA GA 30339 5 +000000000 +0080226I 052461 05241961 6Additional line 1 7and another additional line 10101ABC000029102 N D +3658 MAIN STREET 2 ATLANTA GA3033 +9 0001 3JOHN DOE 05241961INDV37468604 +7S 4 5

Perl reduces RSI - it saves typing

In reply to Re^3: Hash Help by GrandFather
in thread Hash Help by mmittiga17

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.