in reply to Re^2: Problem with DBM hash of anonymous arrays
in thread Problem with DBM hash of anonymous arrays

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.

  • Comment on Re^3: Problem with DBM hash of anonymous arrays

Replies are listed 'Best First'.
Re^4: Problem with DBM hash of anonymous arrays
by travisbickle34 (Beadle) on May 17, 2005 at 11:50 UTC
    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...

        Ah, cheers. I think I have it straight in my head now :-) I can get it to work with an ordinary hash table now, just not the DBM hash! Always problems!