|Think about Loose Coupling|
element of an array of arraysby JockoHelios (Scribe)
|on Jun 17, 2013 at 02:01 UTC||Need Help??|
JockoHelios has asked for the
wisdom of the Perl Monks concerning the following question:
UPDATE I'll state the problem I'm trying to solve, which I didn't do originally. I thought the added detail would just clutter the post, but since I'm still stuck here goes.
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 :
I had considered setting up a while loop with a counter to go through the original data, and using that counter to look back over the last 15 rows. That seems awful clumsy to me, but maybe in this case ! TMTOWTDI...
Original PostI've got an array of arrays from which I can't access single elements. Seems to me I've used this syntax before, but apparently my neurons are misfiring because it's not working the way I think it should.
When trying to retrieve one element of the array of arrays using the form$OneElement = $Records[ 1 ][ 2 ];
I get an error that I can't use a string as an Array ref with strict, and it lists the entire row from the array as the string. It appears that Perl is only using the first index, and returning the entire row. I'm sure this is what I'm telling Perl to do, I just can't see how I'm telling it to do that.Here's a demo code which reproduces the error message. I've commented out the $OneElement assignment so the rest runs. With the last two statements, commenting out the first one results in the same error from the second print statement - only the line number is different.
Anyone seen this (newbie mistake) before ?
Dyslexics Untie !!!