Now my error reads, very much as it did yesterday, only with a new line number:
on the following line:Can't use string ("databasename ") as a HASH ref while "strict refs" i +n use at /usr/lib/cgi-bin/bc/supporters.cgi line 264.
pointing out an additional issue, namely that somehow my database name (still with that annoying trailing space) has somehow been mis-assigned to my db_host_name key in the $config->{'db'} hash.my($host) = $config{'db'}{'db_host_name'};
Since this is a hash slice to scalar assignment, it eliminates me having to wrap my head around the proper syntax for converting multiple element hash slices into arrays.
Again, the block which defines the $config->{'db'} hash reads as follows:
I assign $val to two different elements of the hash here. As an experiment. $config{"$key"} properly passes the values (I suspect), as the .cgi page resolves without error. But $config{'db'}{"$key"} does not, resulting in the error described above.while (<DB>) { chomp; next if /^\s*\#/; next if /^\s*$/; unless (/=/) { die "invalid variable assignment in supporters.db: $_"; } my ($key, $val) = split(/\s*=\s*/,$_,2); $key =~ s/^\s*//; $val =~ s/ *$//g; $config{'db'}{"$key"} = $val; $config{"$key"} = $val; } close DB;
So I guess I can make my script work. But I was hoping to tighten up the code some and do in one line, what I have been doing in five. And I'm still confused about this HASH ref error. What does that mean? Where is this explained for me? How do I avoid it?
All help appreciated.
-- Hugh
In reply to more fun w/ HASh ref's by hesco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |