Hello All,

Once again i call on you for guidence.

Im after putting 5 hases into an array, so i can return it with all five hashes from a method. The 5 hashes are created in the method, which is given two strings as input. The 5 hashes contain data (doesnt matter what it is). In the original call im assigning an array to the array of hashes returned by the method. I then want to extract each hash and assign the complete hash to a new hash.
Here is a sample of my code:

#original call my @array_of_hashes = get_array_of_hashes($value1, $value2); my %probe_name = $array_of_hashes[0]; my %probe_start = $array_of_hashes[1]; my %probe_stop = $array_of_hashes[2]; my %probe_chromo = $array_of_hashes[3]; my %probe_seq = $array_of_hashes[4]; #method sub get_array_of_hashes($$) { my ($value1,$value2) = @_; my %hash_one; my %hash_two; my %hash_three; my %hash_four; my %hash_five; ## DO SOME STUFF HERE TO GET EXTRA DATA in a loop { $hash_one{$some_value} = $some_other_value; $hash_two{$some_value} = $some_other_value; $hash_three{$some_value} = $some_other_value; $hash_four{$some_value} = $some_other_valuee; $hash_five{$some_value} = $some_other_value; } push(@array_of_hashes, %hash_one); push(@array_of_hashes, %hash_two); push(@array_of_hashes, %hash_three); push(@array_of_hashes, %hash_four); push(@array_of_hashes, %hash_five); return @array_of_hashes; }

Im not sure what is wrong here, the error message I get says:

Reference found where even-sized list expected

Any thoughts ?

cheers,
MonkPaul.


In reply to Pulling a hash from within an array by MonkPaul

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.