in reply to Hash Printing Question

${hash}{"key"} is the same as $hash{"key"} (for reasonably named variables) so I'd suggest you adopt the second style for most uses. But in a string expansion, ${var} is used like $var but (at least usually) stops interpretting at the closing } (this is all a bit imprecise in an attempt to be DWIMish) so you can write "Sold $n ${item}s" instead of "Sold $n $item"."s". So "${hash}{'key'}" is the same as $hash."{'key'}".

And $hash{"key"} is the same as $hash{key} if "key" is just letters, numbers, and underscores. So you can use any of these:

print "name is $input_queue{name}\n"; print "name is $input_queue{'name'}\n"; print qq<name is $input_queue{"name"}\n>; print "name is ".$input_queue{"name"}."\n";
to name just a few.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
(tye)Re2: Hash Printing Question
by tye (Sage) on Dec 01, 2000 at 02:05 UTC

    One minor correction:

    And $hash{"key"} is the same as $hash{key} if "key" is just letters, numbers, and underscores.

    I was worried that I didn't get that quite right and for good reason, too. $hash{"012"} is different than $hash{012} which is actually the same as $hash{"10"} since 012 (octal) == 10 (decimal). I worry there may be other special cases as well.

    Also, on slightly old versions of Perl, things like $hash{time} will get you a warning because, on even older versions of Perl, that meant $hash{time()} and we needed a transition period before it could unambiguously mean $hash{"time"} like it does now.

            - tye (but my friends call me "Tye")