in reply to Dereferencing and context?
The difference lies in the fact that Perl automatically flattens all lists in a comma separated expression:
print $_ for @arr1, @arr2is (for this example) the same as
my @temp = @arr1; push @temp,@arr2; print $_ for @temp;
where your second example does not have implicit list flattening as you are dealing with references. Your second example
print @$_ for ( [ 'a' .. 'e' ], [ 0 .. 4 ] );
is equivalent to
print @$_ for \@arr1, \@arr2
and to get the equivalent to your first example, you have to turn the references back into the list elements first, for example by using map, which can return multiple output elements for one element :
print $_ for (map { @$_ } \@arr1, \@arr2);
|
|---|