#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use Data::Dumper; my $ref = [[1, 2, 3], [4, 5, 6]]; # Print an element. say $ref->[1][1]; # Add a row. push @$ref, [7, 8, 9]; # Add a column. my @column = (3.5, 6.5, 9.5); push @{ $ref->[$_] }, $column[$_] for 0 .. $#column; # The same with an array. my @array = ([1, 2, 3], [4, 5, 6]); # Print an element. say $array[1][1]; # Add a row. push @array, [7, 8, 9]; # Add a column. my $column = \@column; push @{ $array[$_] }, $column->[$_] for 0 .. $#$column; Dumper($ref) eq Dumper(\@array) or die "Different";