in reply to Reasoning behind -1 not working in slices?
Assume for a second you have a 4 element array and you want to take the slice 2 .. -2.
Don't you think it violates the principal of least suprise to expect Perl to realize you are taking an array slice, calculate the positive index of the negative offset and then create an ascending range for you?2 with positive offset my @array = (1, 2, 3, 4); -2 with negative offset
Update: Phrased the last question better.
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reasoning behind -1 not working in slices?
by Splutty (Initiate) on Aug 15, 2006 at 13:02 UTC |