in reply to Re: accessing a hash via reference
in thread accessing a hash via reference

Thank you. Thats great.Just one question

Is the difference between

     my %hash = %{$token->[2]}; and

my %hash = $token->[2];

The former trys to assign a string to a hash. Saying something like %hash = HASH(0x86b258)

The latter assigns a hash to a hash by telling perl that whatever is inside %{} is definately a hash.Perl then gos and gets whatever $token->[2] points to and dereferences it.

Replies are listed 'Best First'.
Re^3: accessing a hash via reference
by Fletch (Bishop) on Sep 03, 2006 at 13:56 UTC

    Need for <code></code> tags aside, the first is dereferencing a hash ref into a list and then assigning that list to your hash. The second is attempting to assign the hashref to the hash, which will get you a gripe about assigning an odd number of elements to a hash and a hash with one entry with a stringified representation of the hashref (what you're seeing) as the key.

      Thanks