Your %HoA data structure is defined within your processing loop. Try running your code through Perl::Tidy to see some of the obvious structural problems.

Just do the processing like demonstrated below. You can change it back to file processing on your own:

#!/usr/bin/perl use strict; use warnings; my %HoA; while (<DATA>) { if (/(\d+)\s+(.*?)\[/) { push @{$HoA{$1}}, $2; } else { warn "Unknown data format: $_\n"; } } foreach my $k (sort keys %HoA) { print "$k\n\t@{$HoA{$k}}\n"; } __DATA__ 10 a[ 11 b[ 12 c[ 13 d[ 14 e[ 15 f[ 16 g[ 17 h[ 18 i[ 19 j[ 20 k[ 10 l[ 11 m[ 12 n[ 13 o[ 14 p[ 15 q[ 16 r[ 17 s[ 18 t[ 19 y[ 20 v[
Outputs:
10 a l 11 b m 12 c n 13 d o 14 e p 15 f q 16 g r 17 h s 18 i t 19 j y 20 k v

In reply to Re: Hash of Arrays by wind
in thread Hash of Arrays by rwitmer

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.