Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Confused Still by Hash Refs

by g0n (Priest)
on Feb 03, 2006 at 12:06 UTC ( [id://527606]=note: print w/replies, xml ) Need Help??


in reply to Confused Still by Hash Refs

Your problem is this:

my($userdb,%group) = @_;
if you are calling it with this:

&GroupCreate($userdb,\%group);

You are sending the sub a scalar (I assume) and a hashref, but the assignment

my($userdb,%group) = @_;
is trying to assign a hash, not a hashref, and therefore expecting the parameters after $userdb to be a list (i.e. the contents of the hash itself). As an alternative, try:
my ($userdb,$groupref) = @_; my %group = %$groupref;
my ($userdb,$group) = @_;

FWIW, thats what:

[Thu Feb 2 22:29:32 2006] test-auth5.cgi: Odd number of elements in h +ash assignment at /var/wwwssl/auth-test/test-auth5.cgi line 379.

is telling you.

Update: all the uses of %group in the sub appear to be addressing a hashref $group, with the exception of the assignment, so there's no need to dereference it at all.

--------------------------------------------------------------

"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
John Brunner, "The Shockwave Rider".

Replies are listed 'Best First'.
Re^2: Confused Still by Hash Refs
by hesco (Deacon) on Feb 03, 2006 at 12:22 UTC
    Thank you, sir. That handled the error in test-auth5.cgi at line 379, the "odd number of elements in hash assignment" piece. It leaves me with the hash ref error in the module I'm trying to use, suggesting to me that I'm not sending DBIx::UserDB its arguments in exactly the right manner, somehow. Any further ideas? -- Hugh
      Yep, take a look at DBIx::Userdb. The syntax is:

      group_create(\%hash);

      and you're doing:

      $userdb->group_create ( $group->{groupname} )

      $group->{groupname} isn't a hashref, in fact AFAICT it is the value 'wheel'. Try this:

      $userdb->group_create($group);

      or

      $userdb->group_create({groupname=>$group->{groupname}});

      if you don't want to pass the rest of the contents of %$group in.

      --------------------------------------------------------------

      "If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
      John Brunner, "The Shockwave Rider".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://527606]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-04-18 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found