develooper Front page | perl.beginners | Postings from May 2007

Arrow dereference operator question

Thread Next
From:
David Unric
Date:
May 30, 2007 23:55
Subject:
Arrow dereference operator question
Message ID:
ecf3c6dc0705302355v96c7b41vf94b050f0b70eaaa@mail.gmail.com
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 "]["

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About