>> I need to slice an array such that it gives me the first through the 4th to
>> last in a variable length array.  I thought I could just do:
>> 
>>   @comments[0..-4]
>> 
>> but Perl seems to choke on this.  It's perfectly okay with a slice using two
>> negative #s:
>> 
>>   @comments[-2..-4]
>> 
>> Anyone know why it doesn't like 0..-4?
> 
> The first number HAS to be less then the second number so @array[-4..4]
> and @array[-10..-4] are valid but @comments[0..-4] and @comments[-2..-4]
> are not.  For your original question use:
> 
> @comments[0..$#comments-4]


Thanks, John and Rob!

- B 


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

Reply via email to