From: Rob Richardson <[EMAIL PROTECTED]> > The line of code that is supposed to add the new User object to the > 'users' hash of the UserList object is: > > $self->{'users'}->{$loginName} = $user; #<== This is line 47 > > The error message is: > "Can't use string ("interrobang") as a HASH ref while "strict refs" in > use at UserList.pm line 47, <USERLIST> line 1." > > "Interrobang" is the login name of the only user in the data file I am > testing this script against.
The problem is a few lines above that. > <snipped> > sub Load > { > my $self = shift; > my $fileName = shift; > my $user; > > open (USERLIST, $fileName) || die "cannot open database $fileName: > $!\n"; > if ($^O ne "MSWin32") > { > flock(USERLIST, 1); > } > > while (<USERLIST>) > { > chomp; > AddUser (split /,/); Here is the problem. You are not calling the AddUser() as a method, but as a plain old function ... > } > } > > sub AddUser > { > my $self = shift; yet here you assume that the first argument to AddUser() is the UserList object. What happens is that the first item returned by the split() (the username) is stored in the $self variable and this line > $self->{'users'}->{$loginName} = $user; complains because $self is not a hash reference. You are really lucky you used strict. Otherwise this error would be very hard to find :-) Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]