Re: array slice question

2001-06-26 Thread Michael Fowler
On Tue, Jun 26, 2001 at 04:46:24PM -0400, Bradford Ritchie wrote: > ...but I really need to print everything after the 8th element. If the > ...array were named, I could do something like this: > > @arr = split(/:/); > print @arr[1,6,8..$#arr]); Your asked question was answered well by St

RE: array slice question

2001-06-26 Thread Peter Cornelius
I don't think so. I do (split)[-1] regularly and it works fine. If you left out the parens however it would think this was a pattern to match. I was told by someone on perlmonks that the failure of [3 .. -1] with split is something that should be fixed in subsequent versions of Perl. > > [

Re: array slice question

2001-06-26 Thread royce . wells
[1,6,8..-1] in this case "-" is seen as a metacharacter inside the character class and is not seen as -1 Hi, I have an unnamed array which I created from splitting up a colon separated string: $_ = "0th:1st:2nd:3rd:4th:5th:6th:7th:Some random text: might have :colons: or might n

Re: array slice question

2001-06-26 Thread dave hoover
Bradford wrote: > Hi, > > I have an unnamed array which I created from > splitting up a colon separated string: > > $_ = "0th:1st:2nd:3rd:4th:5th:6th:7th:Some > random text: might have :colons: or might not" > print ((split /:/)[1,6,8]); > > ...but I really need to print everythi

RE: array slice question

2001-06-26 Thread Stephen Nelson
Well, if you're OK with printing the colons in the last field, you could simply say: print ( ( split(/:/, $_, 9) )[1,6,8] ); Since that'll absorb all of the ending fields into the ninth (from zero, so index 8) field. That would be the correct thing to do if the colons in the ending field are not