|laziness, impatience, and hubris|
Array of arrays - reduxby JockoHelios (Scribe)
|on Jun 17, 2013 at 15:50 UTC||Need Help??|
JockoHelios has asked for the
wisdom of the Perl Monks concerning the following question:
I'd posted a problem here and gotten a number of good responses. But since I'm still spinning my wheels, I'll state here a description of the problem I'm trying to solve, which I didn't do in the original post. I thought the added detail would just cloud the issue, but since I'm still stuck here goes.
The original post, with demo code and my confusion both in full display, are here http://www.perlmonks.org/?node_id=1039251I have a large array of arrays, the original data. When going through that data, serially, at each row I need to check back over the previous 15 rows to see if a value exists in a specified field of those previous rows. Call it a look-back. The value I'm looking for can change based on the values in the current row, so this has to be evaulated with every original data row.
I decided to populate a look-back array with rows from the original data. This would be the 15 previous rows. The flow concept goes like this:run through the original data via foreach. For every original data row :
while there are less than 15 rows in the look-back array, push each original data row onto the look-back array
after there are 15 rows in the look-back array, scan the look-back array for the specified value,
then shift the first row off of the look-back array and push the current original data row onto the look-back array
repeat until the end of the original data
The look-back array would thus always have the previous 15 rows, based on the current original data row.Where I'm stuck is at the look-back array. I'm unable to come up with the code to pull out a specified field from each row of the look-back array (of arrays). I've tried several methods to get the original data rows into the look-back array, and more methods to pull the specified element from it, but all I've gotten are error messages. Am I pounding my head against the wall here ? Is this flow concept so far off the mark that it can't be done ?
I had considered setting up a loop with a counter to go through the original data, and using that counter to look back over the last 15 rows. That seems clumsy to me, but maybe in this case ! TMTOWTDI...
Dyslexics Untie !!!