kudos for "use strict" and "use warnings"

Understanding the error message can give clues as to what could the matter be...
"Reference found where even-sized list expected at arrayTest_monk.pl line 38."

is a warning that tells you that perl is trying to make a hash out of a passed list, and since hashes are associative (they have key/value pairs) hence for the set to be complete an even-sized list has to be passed so that each key would have its associated value..That wouldn't be detectable were you not invoking warnings! consider the following:

use strict; use warnings; my @keyVal1 =qw(something 1 another 2); my @keyVal2 = qw(SOMETHING 1 ANOTHER); my %hash1 = @keyVal1; my %hash2 = @keyVal2; use Data::Dumper; print Dumper(\%hash1); print "\n"; print Dumper(\%hash2);

Since each member of @deRefHashArray is a hash then inspecting the warnings would show you that you haven't dereferenced it appropriately..

have been of great benefit to me and so wish they would be to you too..

Here's your code after minor touches to get you started
#!/usr/local/bin/perl use Data::Dumper; use strict; use warnings; my $hashArrayRef; $hashArrayRef = [{ 'dateOfBirh' => '22 March 1971', 'firstName' => 'Ronnie', 'lastName' => 'Smith' }, { 'timeNow' => '14 April 1972', 'firstName' => 'Claudia', 'lastName' => 'Winkleman' }]; print Dumper(\@$hashArrayRef); #Properly dereferenced..compare output print "\n"; print Dumper(@$hashArrayRef); print "\n"; for (my $counter = 0; $counter <= $#$hashArrayRef; $counter++) { while ( my ($key, $value) = each(%{@$hashArrayRef[$counter]}) +) { print "$key => $value\n"; } }
wish you a nice Perl journey...


Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

In reply to Re: arrays, hashes, dereferencing confusion - need help by biohisham
in thread arrays, hashes, dereferencing confusion - need help by Klunk

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.