Based on perlref documentation arrow operator between brackets subscripts
may be omitted so the following code is valid:

@array = ( [1, 2], [3, 4] );
$element = $array[0][0];    #  shorthand for  $element = $array[0]->[0]


Could somebody explain why it causes syntax error when the above rule is
applied to returned value of a subroutine ?

sub mysub {
   @array = ( [1, 2], [3, 4] );

   return @array;
}

$element = (&mysub)[0][0];   # $elem = (&mysub)[0]->[0] is valid
------------------------------
syntax error at testarr.pl line 7, near "]["

Reply via email to