bar10der has asked for the wisdom of the Perl Monks concerning the following question:

Hi There,

I am getting "Odd number of elements in hash assignment at ..." in my script. This is what I am doing-
From main routine I am calling a local sub routine.

#Main routine
#All vars declaration etc...

my %Data = getData( UserID => $UserID, QueueID => 0, ShownQueueIDs => \@QueueIDs, );

#Continue processing

#####Sub routine

sub getData{ print "getDatais called\n"; my $Self = shift; my %Param = @_; return; }

I am getting error at line "my %Param = @_;"

Though my code is compiled without error..

Any help will be greatly appreciated.

Thanks

Replies are listed 'Best First'.
Re: hash element error
by Beechbone (Friar) on Mar 10, 2009 at 09:53 UTC
    You are giving 6 arguments to getData(). The first one ("UserId") you shift() into $self, the other 5(!!!) you assign to %Param.

    Looks to me as if getData was designed to be a method, not a sub...


    Search, Ask, Know