My browser reports:
Here is the debugging output I'm sending to the error log:Software error: Can't use string ("wheel") as a HASH ref while "strict refs" in use at + /usr/local/share/perl/5.8.7/DBIx/UserDB.pm line 410.
I'm using this syntax:New UserDB object created. The $session ID is: 77540362YTIvQiAaOS7yA942A153i62p32351f159U25f59k22l181r1112198r113k146 +y85A21O160w104393P643515121S122n190n96A21067w174n66c98l100j95w174e13j +125g293123n96B60G9EPZdZYJ4zjW1. About to enter dispatch code. $function is NewGroup. [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. GroupCreate received these arguments: $userdb is DBIx::UserDB=HASH(0x84febec). The new group name is: wheel. $group is HASH(0x84fecac). Creating a new group called: wheel. ref of group = ref(HASH(0x84fecac)) ref of groupname = ref(wheel) [Thu Feb 2 22:29:32 2006] test-auth5.cgi: Can't use string ("wheel") +as a HASH ref while "strict refs" in use at /usr/local/share/perl/5.8 +.7/DBIx/UserDB.pm line 410.
to call a subroutine which includes line 379, the line which accepts @_ and parses it at the top of the following snippet.&GroupCreate($userdb,\%group);
And line 410 which throws that other error is in this subroutine in a distinct module, on the line which defines $old_group.sub GroupCreate() { my($userdb,%group) = @_; print STDERR "GroupCreate received these arguments: \n\t\$userdb is +$userdb. \n\tThe new group name is: $group->{groupname}.\n\t\$group +is $group.\n"; return p("Groupname required to create new group.") unless defined($ +group->{groupname}); my($status,$gid); print STDERR "Creating a new group called: $group->{groupname}.\n"; print STDERR "\tref of group = ref($group) \n\tref of groupname = re +f($groupname) \n"; { no strict 'refs'; my $result = $userdb->group_create ( $group->{groupname} ); } if($result) { $status = p("A New Group, called <b>$group{groupname}</b> has been + successfully created, with GID: $group->{'gid '}."); } else { $status = p("The creation of a new Group, called <b>$group{groupna +me}</b> failed."); } return $status; } # END GroupCreate
If this is too confusing to be helpful and you've successfully used DBIx::UserDB, I'd be happy for the moment simply having some working code snippets I could adapt from.sub group_create { my ( $self, $group ) = @_; my $DB = $self->{DB}; # Check for group with same name my $old_group = $DB->record_search( $self->{group_profile}, { groupname => $group->{groupname} } ); return undef if @$old_group; $DB->record_insert( $self->{group_profile}, $group ); my $new_group = $DB->record_search( $self->{group_profile}, { groupname => $group->{groupname} } ); die "Failed to find newly created group\n" unless @$new_group == 1 +; # Copy the fields of the new user back in this one while ( my ($name,$value) = each %{$new_group->[0]} ) { $group->{$name} = $value; } return $group; }
-- Hugh
In reply to Confused Still by Hash Refs by hesco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |