We don't bite newbies here... much | |
PerlMonks |
Re: Manipulating Array Indexesby kcott (Archbishop) |
on Sep 08, 2020 at 03:55 UTC ( [id://11121480]=note: print w/replies, xml ) | Need Help?? |
G'day TJ, Welcome to the Monastery. There are some edge cases you didn't consider (or, at least, didn't tell us about) so here's a couple of options. I've extended your posted input to show: 5 at the start; 5 in the set of 3 returned; and, running out of elements at the end.
If, on the other hand, you don't want sets of less than 3 returned, you can simplify the map and don't read the last 3 indices.
Both of those solutions work with input such as (), (5), and (1,2,3,4). Although you say that you're expecting long arrays, it's always a good idea to add a sanity check for those times when your process is handed something unexpected, like one of those short lists. — Ken
In Section
Seekers of Perl Wisdom
|
|