on Fri, 30 Aug 2002 14:29:40 GMT, [EMAIL PROTECTED] (Alex B.) wrote:
> 1. how do I assign new dynamic arrays, like @a25 if there is 25
> rows? or lets say there is 78 rows, then I don't really want to
> type "my @a00 = ();" through "my @a77 = ();" using the strict
> module... is there a way of solving that problem?
You use an array of array(refs):
my @array = ();
$array[0] = [ 1, 2, 3];
$array[1] = [ 4, 5, 6];
#...
$array[77] = [232,233,234];
You can then access individual elements with the following syntax:
print $array[3][1]; # prints 11
> 2. I would like to sort the array of arrays by specifying a
> certain element of an array inside the big array.
> Lets say array00 in the big surrounding array consists of
> ("McNew", "Matthew", "[EMAIL PROTECTED]") and array01 ("Clarich",
> "Paul", "[EMAIL PROTECTED]") I'd like to reorder the arrays 00 and 01 so
> that if I sort by the last name array00[0] and array01[0], that
> array01 is infront of array00...
my @sorted_array = sort { $a->[0] <=> $b->[0] } @array;
(You may want to use 'cmp' instead of '<=>', since you want to sort
ASCIIbetically.)
--
felix
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]