John Siracusa writes:

> Call me crazy, but at this point I'm prone to stick with what I've done in
> Perl 5 for years:
> 
>     $var{'key1'}{'key2'}[3]{'key3'}

In which case do that, since it'll still work in Perl 6.

Actually, it works 'better' in Perl 6, since it doesn't mislead in any
way.

I've encountered several Perl programmers who feel 'uneasy' about the
auto-quoting rules of hash keys, so choose not to bother with them and
put all the quotes in as you do above.  The trouble with that in Perl 5
is that it gives the impression that the quotes are actually doing
something.  That then leads to bugs like writing:

  $log{time} = $msg;

where because the programmer has explicitly _not_ used quotes and want
to invoke a function rather than use the literal string "time".  But
because in fact the quotes weren't doing anything, removing them doesn't
change anything.

That awkwardness is fixed in Perl 6: because the quotes _are_ now needed
with the C< $hash{'key'} > syntax when you want to quote, you can not
have quotes when you don't want to quote (and Perl will automatically
not quote it for you!).

So life is better for people who like writing hash subscripts as you do.
But for those who like autoquoting, there's now a different syntax, one
that doesn't interfere with the above syntax at all.  You don't have to
use it if you don't want to, and everybody's happy!

Smylers

Reply via email to