An array cannot be the key of a hash. Perl stringifies hash keys, so that hash keys are always strings. Even if you tried something like this:
$hash1{\@elements}++;
or
$hash1{[@elements]++;
it would not work, because your key would end up being a stringified array ref (and the array content would be lost).

So either you want to use the string that you've read to be the hash key

$hash1{$line}++;
but that does not seem to be very useful in this context, or you want to store an array reference into the value of the hash
$hash1{"some key"} = \@elements;
but then I am not sure what you would want your key to be.

I think you need to have (and provide us) a clearer idea of the data structure that you want to have at the end of your process.

Quite possibly you really need an array of arrays, rather than a hash of arrays. Quick demonstration under the Perl debugger:

DB<1> @elements = qw/ 1 3 5 4 6/; DB<2> push @array, \@elements; DB<3> @elements2 = qw/ 12 13 14 15/; DB<4> push @array, \@elements2; DB<5> x \@array 0 ARRAY(0x600509af0) 0 ARRAY(0x600500b38) 0 1 1 3 2 5 3 4 4 6 1 ARRAY(0x600500928) 0 12 1 13 2 14 3 15
Update: Perhaps I misunderstood your requirement. Please read my next answer on Aug 17, 2014 at 08:50 UTC (immediately below)


In reply to Re^3: Hashes, keys and multiple histogram by Laurent_R
in thread Hashes, keys and multiple histogram by f77coder

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.