On May 31, 7:55 am, [EMAIL PROTECTED] (David Unric) wrote: > 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 "]["
the sub mysub should pass an array ref ([EMAIL PROTECTED]) not the array (@array). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/