in reply to array pushing
Now, concerning $ARRAY[++$#ARRAY] = $value;. Array elements are accessed by $array[$index]. So to access the second element in the array @array you would write $array[1]. It is a one because array indexes start at 0. Now, the $#ARRAY syntax is a special way of saying @array - 1; basically, it returns the index of the last element in @ARRAY. The ++ increments this value and then uses it as the new index, which it sets equal to $value.
As for the other question, this should work... Hopefully it gives you an idea of how to do things. Read up on sort if you don't get that part.
while (($this, $that) = each(%list)) { push @array, $this, $that; } @array = sort { $a <=> $b } @array;
I hope that helps. You may also want to read the very helpful article "List" Is a Four-Letter Word.
Added part about the "list into array" thing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: array pushing
by chromatic (Archbishop) on Apr 25, 2003 at 23:31 UTC |