Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

hash element error

by bar10der (Beadle)
on Mar 10, 2009 at 09:47 UTC ( #749539=perlquestion: print w/replies, xml ) Need Help??

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.


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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://749539]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2021-09-19 15:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found