There is no "PHASH". There is a $PAHASH, which is a scalar containing a reference to an anonymous hash and there is a %PAHASH, which is a hash (tied to a dbm file), but is unrelated to $PAHASH.
If you do $PAHASH{$something} you're refering to %PAHASH. If you do $$PAHASH{$something}, you're referering to the hash referenced by $PAHASH. This can be confusing in the beginning, I know.
Take a look at perlreftut. But most of all, get in the habit of using strict. It'll save you from a lot of bugs.
| [reply] |
The way I saw it was like this:
%PAHASH is a named hash.
$PAHASH{key} is referring to a scalar value stored in %PAHASH.
$$PAHASH{key}[index] is referring to a (dereferenced) scalar value, stored in an anonymous array which is a value in %PAHASH.
This is wrong, then?
Sorry if this seems stupid by the way...
| [reply] [d/l] [select] |
Yes this is wrong :-) It parses like:
$PAHASH->{$key}->[$index]
# hashref-> hash ->array
While you want
$PAHASH{$key}->[$index]
# hash element ->array
Which can also be written as
$PAHASH{$key}[$index]
update: Or maybe you want
${$PAHASH{$key}[$index]}
If you really want the value as a reference to a scalar (I don't see the point of doing it)
| [reply] [d/l] [select] |