# [] constructs an anonymous array, so we use that. # several ways to do it - choose any (not all :-) my $anon_array = []; # gimme an anonymous array and # assign it to $anon_array @$anon_array = @line; # assign to the anonymous array push(@matrix, $anon_array); # shortcut: $anon_array = [ @line ]; push(@matrix, $anon_array); # compacting further: split returns a list, use that # to populate an anonymous array on the fly, push that # (the SCALAR value which is an array reference) onto # the array @matrix push(@matrix, [split(/\s+/, $filecontents[$i])]); }