in reply to Re^3: More efficient dereferencing of a subroutine return
in thread More efficient dereferencing of a subroutine return

Is there a way to avoid this multi step operation when I have multiple return values of a sub?

Yes:

sub fillArrays { my( $r1, $r2 ) = @_; my @$r1 = qw(one two three); my @$r2 = qw(four five six seven); return; } my (@arr1,@arr2); fillArrays( \@arr1, \@arr2 );

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.

Replies are listed 'Best First'.
Re^5: More efficient dereferencing of a subroutine return
by AnomalousMonk (Archbishop) on Feb 19, 2013 at 23:26 UTC

    This also works and is 'shorter', although I would not say more maintainable:

    >perl -wMstrict -MData::Dump -le "sub fillArrays { my( $r1, $r2 ) = @_; @$r1 = qw(one two three); @$r2 = qw(four five six seven); } ;; fillArrays( \my (@arr1, @arr2) ); ;; dd \@arr1, \@arr2; " (["one", "two", "three"], ["four", "five", "six", "seven"])
      Thanks to all of you. I am going to stick to the "keep it simple, stupid" philosophy even though it is more lines and typing. I appreciate everyones' replies.