On Thu, 2003-11-13 at 18:25, Dan Anderson wrote:
> Is there a way to "peek" at the top or bottom of an array?  Sort of like
> pop or shift but without needing to insert the value back into the
> array?
> 
> I suppose I could do something like:
> 
> my $check_me = pop @array;
> push @array, $check_me;
> 
> But that seems kind of inelegant and verbose.

Dan,

If I understand your question correctly, the first element of the array
is always 0 and the last is always -1, so why can't you just call them
like this


$firstelement = $array[0]; # "peek" at the first element

$lastelement = $array[-1]; # "peek" at the last element

Hope this helps,
Kevin

-- 
Kevin Old <[EMAIL PROTECTED]>


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

Reply via email to