On Tue, Aug 29, 2000 at 07:27:15PM -0700, Peter Scott wrote:
> > $r->{{qw(a b c d e f g h)}}
> > $r->{a}->{b}->{c}->{d}->{e}->{f}->{g}->{h}
>
> $r->{a}{b}{c}{d}{e}{f}{g}{h}
>
> which is only one character longer than the proposal...
Except in the case where you don't have the list until run-time. I made a
class once that emulated the hierarchical structure of a filesystem using a
deep hash of hashes. It had an accessor something like:
$obj->file(qw(usr local bin gpg));
or
$obj->file("/usr/local/bin/gpg"); # which would get split
(I'm paraphrasing and changing syntax, because I don't actually recall the
actual syntax I came up with.)
The accessor would traverse down the internal hash of hashes to retrieve the
information about /usr/local/bin/gpg. With current syntax this is rather
awkward, resulting in code something along the lines of:
my $cur = $hoh;
foreach my $file (@_) {
if (exists $$cur{$file}) {
$cur = $$cur{$file};
} else {
# error
}
}
So the syntax would be useful; I'm not sure how useful, such deeply nested
hashes requiring run-time key lookup like that are a rarity. The array
syntax would also be useful in multi-dimensional arrays.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--