Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I've run across the error from the title in an odd and frustrating manner. In writing the edit-record function, I created a large form, each element of which I named, for consistency, the same name as the corresponding db field. The user makes whatever edits they wish, and the form get submitted to a second file (submit.html) which in turn hands \%ARGS to the subroutine Green::modifyRec, like so:
submit.html:
Green.pm:[...] if ((my $foo = Green::updateRec(\%ARGS))) { [...]
So far, so good, or so I thought. Initially, the troubling line was this one, which returned the error above, specifically as "Can't use string ("precinct") as HASH ref in line 96":sub updateRec { $new = shift @_; [...]
I figured I had a problem with the word itself -- though it's kind of nonintuitive to have it fuss about a string in the MIDDLE of a line -- so I first renamed it, and then removed it entirely.$sth->execute($new->{first}, $new->{middle}, $new->{last}, $new +->{address}, $new->{city}, $new->{state}, $new->{zip}, $new->{email}, + $new->{county}, $new->{precinct}, $new->{region}, $new->{home}, $new +->{other1}, $new->{other2}, $new->{work}, $new->{ext}, $new->{occupat +ion}, $new->{id});
No joy; it was clearly being vexed by "precinct" 's existence in the HASH on a basic level, not because of something being done here. Additionally, removing this line and simply trying to address the hash in a simple debugging line like this:
Still produces the error. Removing "precinct" from the original form, of course, keeps it from complaining about that particular string, but it moves on to another one.print STDERR "\n SHAZAM!!!! $new->{middle} \n";
It seems clear that I'm doing something wrong on a basic level; the code is not complex, but I can't for the life of me figure it out. It does seem likely that either (1) someone will slap me with the answer quickly or (2) I'll realize the answer as soon as I press "submit" on this post. I really don't care which.
Thanks in advance.
Chet Farmer
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Ah, the old "Can't use string ("string") as a HASH ref"
by etcshadow (Priest) on Oct 22, 2003 at 22:42 UTC | |
|
Re: Ah, the old "Can't use string ("string") as a HASH ref"
by antirice (Priest) on Oct 22, 2003 at 22:53 UTC | |
|
Re: Ah, the old "Can't use string ("string") as a HASH ref"
by bobn (Chaplain) on Oct 22, 2003 at 22:36 UTC |