in reply to Skip return values

If you return array reference like my $arr=[1,2,3,4]; return $arr. Then you can achieve what you expect as follows

my $c=@{&sample}[2];

Replies are listed 'Best First'.
Re^2: Skip return values
by AnomalousMonk (Archbishop) on Apr 03, 2009 at 07:21 UTC
    And, if returning an array reference, yet another way:
    >perl -wMstrict -le "sub sample { return [1, 2, 3, 4]; } my $c = sample()->[2]; print $c; " 3
    BTW: The  &sample form of subroutine invocation is deprecated.
      You are passing @ARGV to sample. Thats why the syntax &subroutine is bad TM. Its not just cosmetically ugly.

      print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});