in reply to array ref notation

Is there a practical reason for the 2nd example?

Orthogonality. Without the curly braces @$a[1] is unintuatively equivalent to @{$a}[1]:

$a = [ [1],[2],[3] ];; print @$a[1];; ARRAY(0x1b7ae0) print @{$a}[1];; ARRAY(0x1b7ae0)

Instead of:

print @{ $a[1] };; 2

You can get away with not using the curlies for a single depth dereference, but it is required for greater depths.

And this is an error:

print @$a->[1];; Using an array as a reference is deprecated at (eval 15) line 1, <STDI +N> line 7. ARRAY(0x1b7ae0)

That needs to be this:

print @{ $a->[1] };; 2

I find it easier to always use the curlies rather than have to think about the exceptions.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.