in reply to Error hash declaration

my %hashofstates; << This declares a hash : "%hashofstates" .

$hashofstates->($key) << This attempts to access a SCALAR REFERENCE : "$hashofstates" , a totally different animal that does not exist.

The distinction between the hash and the hash-ref is the use of the DEREFERENCING operator "->".

You probably wanted:

$hashofstates{$key}
Also note the use of Curly brackets (Not parens) to contain hash keys.

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams

Replies are listed 'Best First'.
Re^2: Error hash declaration
by sidsinha (Acolyte) on Aug 30, 2014 at 00:23 UTC
    Thankyou!