more useful options | |
PerlMonks |
Re: Manipulating Array Indexesby roboticus (Chancellor) |
on Sep 07, 2020 at 16:19 UTC ( [id://11121445]=note: print w/replies, xml ) | Need Help?? |
Yes, you can access other elements in the array by doing math with the index. There are lots of ways you could do it, but I'll demonstrate with two: you can do it as a two pass operation to first find all the targets, and then loop over your target list to print your results; or you could try to do it in a single pass over the array.
It looks like you're trying to use the first method, but you didn't show enough code for me to figure you what difficulty you're having. The second method can work well also, but can be a bit more confusing at first. Other things that can make your life tricky are:
So try not to do either of those. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|