On Mon, May 14, 2001 at 08:38:31PM +0100, Graham Barr wrote:
> > What is the meaning of the following four expressions in Perl6?
> > @bar[$foo];
> > %bar{$foo};
> > @bar{$foo};
> > %bar[$foo];
> $bar[$foo];
> $bar{$foo};
It's really, really easy. Just stick a -> between the variable and
the brace, and you have Perl 5.
@bar[$foo] in Perl 6 is @bar->[$foo] in Perl 5.
(Which, by magic, turns into what most people refer to as $bar[$foo])
%bar{$foo} in Perl 6 is %bar->{$foo} in Perl 5.
(By the same magic, this is $bar{$foo});
@bar{$foo} in Perl 6 is (almost) @bar->{$foo} in Perl 5.
Even looking at it, you can tell it makes no sense. (But Perl 5 does magic
on it anyway, so that's not the best example)
%bar[$foo] in Perl 6 is (almost) %bar->[$foo] in Perl 5.
That's similarly nonsensical, but Perl 5 is still magic.
$bar[$foo] in Perl 6 is $bar->[$foo] in Perl 5.
$bar{$foo} in Perl 6 is $bar->{$foo} in Perl 5.
--
IDIOCY:
Never Underestimate The Power Of Stupid People In Large Groups
http://www.despair.com