[EMAIL PROTECTED] wrote:
> Hi,
> 
> I have a couple of arrays which have different number of
> values - I need only the last value in each - are there a command to
> do that? 
> 
> e.g
> 
> $array[LAST]  :-)

Negative subscripts count from the end of the array, so the last element is:

   $array[-1]

You can also use the $#array notation to get the index of the last element:

   $array[$#array]

The total number of elements can be determined by using the array name in
scalar context. Array indices start at 0, unless you monkey with $[, which
is discouraged. So you could also use:

   [EMAIL PROTECTED] - 1]

Most folks would probably just use $array[-1]

If you want to get the last element and remove it from the array, just use
pop:

   my $last = pop @array;

> 
> or maybe a way to count each value in a given array? and then
> feed the $array[??] with that?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to