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=1039251
I 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...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.