#!/usr/bin/perl -w use strict; # Build the table my $table_ref; for my $row (1..5) { for my $col (1..4) { my @results = rand_vals(4); $table_ref->[$row][$col] = \@results; } } # Use the table for my $row (1..5) { for my $col (1..4) { print "["; # Let Perl walk through the array for us #for (@{$table_ref->[$row][$col]}) { # print "$_ "; #} # Or index our way through the array explicitly for (0..$#{$table_ref->[$row][$col]}) { print "$table_ref->[$row][$col][$_] "; } print "] "; } print "\n"; } # Just a little tool for demo purposes sub rand_vals { my $elements = shift; my @ary; push @ary, int rand(9) for 1..$elements; return @ary; }