in reply to Re: How to declare arrays and scalars together?
in thread How to declare arrays and scalars together?

"Remember why you can not pass multiple arrays to a subroutine?"

except, one uses reference like so:

my $arr1_ref = [ 1, 2, 3 ]; my $arr2_ref = [ 10, 9, 8, 7 ]; load_arr( $arr1_ref, $arr2_ref ); ## load multiple array references sub load_arr { my ( $arr1_def, $arr2_def ) = @_; print join "\n", @{$arr1_def}, @{$arr2_def}; return; }

Replies are listed 'Best First'.
Re^3: How to declare arrays and scalars together?
by Anonymous Monk on Jun 18, 2012 at 16:49 UTC

    You're passing array references there, not arrays.

      That is my point. It is possible to pass multiple arrays, using array reference.

        That is my point. It is possible to pass multiple arrays, using array reference

        Well, you missed the point of Re: How to declare arrays and scalars together? which is, you're only passing lists, you cannot pass an array, an array and an arrayref aren't identical, you need to de-reference an arrayref, but not an array

        Given my @one = (1,1); my @two = (2,2);

        This  foo( @one, @two ); is basically the same as  foo( 1,1,2,2 );

        With the appropriate prototype  foo( @one, @two ); could also be basically the same as  foo( \@one, \@two );

        If you use  foo( \@one, \@two ); then in sub foo you would need to write     my( $oneref, $tworef ) = @_; which is not the same as  my( @one, @two ) = @_;

        You're always passing lists to subroutines