> Is there a way to "peek" at the top or bottom of an array?

for the first element you could "peek" like:
$first = $array[0];

for the last element you could "peek" like:
$last = $array[$#array];

$# indexes the last element of the array.  just make sure you use the same
array's name in the index after $#

- Amit

"Dan Anderson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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.
>
> Thanks,
>
> Dan
>



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

Reply via email to