in reply to beginner question - why is hash key unquoted and in capitals

This "CALLBACK" is a so-called bareword and in certain places (e.g. here when used as hash-key) barewords are implicitely quoted.

So $hash{CODEREF} and $hash{"CODEREF"} are the same thing.

Another typical usage would be

my %hash = ( HUBBA => 1, BUBBA => 2 );
Again the keys to the hash are implicitely quoted.

However you have to be careful when you use non-chars in the key: $hash{HUBBA-BUBBA} will not work as the Perl-parser parses the key as an expression and you get an error (you would have to quote explicitely here: $hash{"HUBBA-BUBBA"}.

The use of all-caps is only a matter of taste and has no significance.

Replies are listed 'Best First'.
Re^2: beginner question - why is hash key unquoted and in capitals
by morgon (Priest) on Oct 16, 2010 at 16:45 UTC
    There is one more thing that may be worth knowing:

    While you cannot use $hash{HUBBA-BUBBA} (see earlier posting) is is perfectly legal (even under strict) to use e.g. $hash{-HUBBA}.

    The rationale for this is I believe the fact that options traditionally (in some systems) start with a "-".

    $hash{+HUBBA} however is illegal.