Splutty has asked for the wisdom of the Perl Monks concerning the following question:
LS,
I ran into a problem I've run into before. I have been coding in LPC for entirely too long, and it's a standard range selection there to use [4..-1] to reference array (or string) slices.
Is there any reason why in perl [-1] gives me the last element of an array, but [4..-1] doesn't give me the 5th through last element as a slice?
(And yes, I do know that [4..$#arr] works, however that isn't the question :)
Splutty.
ps. Sorry about the silly formatting, let me see if I can fix that.
20060815 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reasoning behind -1 not working in slices?
by davidrw (Prior) on Aug 15, 2006 at 12:41 UTC | |
|
Re: Reasoning behind -1 not working in slices?
by Limbic~Region (Chancellor) on Aug 15, 2006 at 12:46 UTC | |
by Splutty (Initiate) on Aug 15, 2006 at 13:02 UTC | |
|
Re: Reasoning behind -1 not working in slices?
by jhourcle (Prior) on Aug 15, 2006 at 11:38 UTC |