Perl 6 still has references -- you can still take an explicit reference like \@array. However, Perl 6 will automatically take a reference or dereference a reference depending on context. Here are a few examples of Perl 6 with the Perl 5 in the comment.
This can surprise a Perl 5 veteran because the code $length = @array won't work the same anymore. (This is a good thing for beginning Perl 6 programmers though!)my %x = ( a => 1 ); # same my $y = %x; # $y = \%x %x{a} = 1; # $x{a} = 1 $y{a} = 1; # $y->{a} = 1
However, Perl 6 has more contexts than Perl 5 -- numeric and boolean contexts -- so some Perl 5 idioms still work. For example, if (@array) ... still works because the 'if' uses boolean context. $length = @array + 0 works because '+' uses numeric context.
Of course, arrays are now objects, so the simplest way to get the length of an array is @array.length.
For more information about variables in Perl 6 check out Apocalypse 2.
In reply to Perl6: same great references, new improved syntax
by blssu
in thread Perl6 - value vs. reference issues
by John M. Dlugosz
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |