Re: peeking at the top or bottom of an array

2003-11-14 Thread Amit Phatak
> 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

Re: peeking at the top or bottom of an array

2003-11-13 Thread Amit Phatak
> 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

Re: peeking at the top or bottom of an array

2003-11-13 Thread drieux
On Thursday, Nov 13, 2003, at 15:25 US/Pacific, 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, $ch

Re: peeking at the top or bottom of an array

2003-11-13 Thread Kevin Old
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_m

Re: peeking at the top or bottom of an array

2003-11-13 Thread Dan Anderson
In case anyone is wondering why I want to do this, I am running through an array (popping out all elements) in order. Some things from the array act differently depending on what is left or right of them (if I'm shifting or popping respectively). I want to double check before I pop or shift. -Da

RE: peeking at the top or bottom of an array

2003-11-13 Thread Tim Johnson
How about: my $check_first = $array[0]; my $check_last = $array[-1]; -Original Message- From: Dan Anderson [mailto:[EMAIL PROTECTED] Sent: Thursday, November 13, 2003 3:25 PM To: 'Beginners Perl' Subject: peeking at the top or bottom of an array Is there a way to "peek

peeking at the top or bottom of an array

2003-11-13 Thread Dan Anderson
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