in reply to Creating multidimentional arrays dynamically
Here's a 2D example, using neat Perl syntax:
Extending this to three dimensions is trivially easy, just add another set of brackets after [$j], but then printing it gets harder. Read perllol#!/usr/bin/perl use strict; use warnings; my @x; for my $i (0..3) { for my $j (0..3) { $x[$i][$j]=int rand 10; } } for my $i (0..3) { for my $j (0..3) { print $x[$i][$j]," "; } print "\n"; } exit;
HTH,
SSF
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Creating multidimentional arrays dynamically
by AnomalousMonk (Archbishop) on Aug 13, 2010 at 09:51 UTC |
In Section
Seekers of Perl Wisdom