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:
to name just a few. - tye (but my friends call me "Tye")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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re2: Hash Printing Question
by tye (Sage) on Dec 01, 2000 at 02:05 UTC |