in reply to Correct keys in hashes
In older versions of perl, there was at least one good reason to prefer $hash{'name'} to $hash{name}. Observe:
$ perl -v This is perl, version 5.004_04 built for sun4-solaris $ perl -lwe 'use strict; sub ambiguous { } my %hash; $hash{ambiguous}= +5; print "but not fatal"' Ambiguous use of {ambiguous} resolved to {"ambiguous"} at -e line 1. but not fatal
So, if you're really worried about backwards compatibility (or, as in my case, you're stuck using an old perl via a CGI server), it might be beneficial to use the quotes. (I can't tell exactly, but it looks like this was fixed in 5.005_something)
Update: what kwoff said: better example of CGI-related error that not-quoting leads to.
|
|---|