in reply to array of hashes

%one = { 1 => 'mili', 2 => 'brown', 3 => 'kalu' };
Wrong. You should decide on whether you want to use a hash, in which case you must use normal parens; or a hash ref, in which case you can the curly braces. Thus, choose between:
%one = ( 1 => 'mili', 2 => 'brown', 3 => 'kalu' );
and
$one = { 1 => 'mili', 2 => 'brown', 3 => 'kalu' };
Note that %one and $one are not the same variable, and you use them differently. So you have to adapt the rest of your code to this choice.

I see you've made this same mistake several times in your code.

Replies are listed 'Best First'.
Re^2: array of hashes
by AnomalousMonk (Archbishop) on Feb 10, 2011 at 21:55 UTC

    It would also be wise for a novice Anonymonk to use diagnostics; in addition to both strict and warnings in his or her code:

    >perl -wMstrict -le "use diagnostics; ;; my %hash = { foo => 'bar' }; " Reference found where even-sized list expected at -e line 1 (#1) (W misc) You gave a single reference where Perl was expecting a list with an even number of elements (for assignment to a hash). This usually means that you used the anon hash constructor when you meant to use parens. In any case, a hash requires key/value pairs. %hash = { one => 1, two => 2, }; # WRONG %hash = [ qw/ an anon array / ]; # WRONG %hash = ( one => 1, two => 2, ); # right %hash = qw( one 1 two 2 ); # also fine