in reply to [untitled node, ID 216639]
Chapter 2 in the Advanced Perl Cookbok deals with matricies. To quote 2.2:
@matrix = ( [1, 2, 3], [4, 5, 6], [7, 8, 9] ); # Change 6, the element at row 1, column 2 to 100 $matrix[1][2] = 100;
You can also use a hash representation of the same matrix. (quoting 2.2 again)
$matrix{0}{2} = 100; $matrix{1}{0} = 200; $matrix{2}{1} = 300;
As you dont need to preinit data structures in perl, you can just add a new cell by doing something like: $matrix{1}{0}{0} = 400;
Update: I asked something about variable variables one other time here. It lead me to the conclusion it wasnt really a good idea.. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Variables in variable names
by dbp (Pilgrim) on Nov 30, 2002 at 23:43 UTC |