in reply to How to declare arrays and scalars together?

As such, nothing looks/IS wrong in your code. It's just that it does not work the way you are thinking it would.
my (@arr1, @arr2, $var, @arr3) = ( (1,2),(11,22),"0", () ); print "\n[@arr1]"; print "\nvar is $var";
RHS of first line is flattened into a single list and copied in its entirety into @arr1.
All other elements in LHS of first line are empty. Remember why you can not pass multiple arrays to a subroutine?

Replies are listed 'Best First'.
Re^2: How to declare arrays and scalars together?
by 2teez (Vicar) on Jun 18, 2012 at 05:36 UTC

    "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; }

      You're passing array references there, not arrays.

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