in reply to Using eval to build array structure
use strict; my @gameboard = ( [ 1, 2, 3, 4, 5 ], [ 2, 3, 4, 5, 1 ], [ 3, 4, 5, 1, 2 ], [ 4, 5, 1, 2, 3 ], [ 5, 1, 2, 3, 4 ], ); for my $i (1 .. 4) { for my $j ($i + 1 .. 5) { if ($gameboard[$i][0] == $gameboard[$j][0]) { print "Matched $i,0 and $j,0\n"; } } }
These are called array references. It's the way Perl (from 5.000 onwards) does multi-level data structures. Read up on them - they'll make your life very easy.
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re(2): Using eval to build array structure
by meta4 (Monk) on Jul 17, 2002 at 17:20 UTC | |
by Popcorn Dave (Abbot) on Jul 17, 2002 at 18:17 UTC |