Think about Loose Coupling | |
PerlMonks |
manipulating a matrixby chexmix (Hermit) |
on Apr 25, 2008 at 13:57 UTC ( [id://682828]=perlquestion: print w/replies, xml ) | Need Help?? |
chexmix has asked for the wisdom of the Perl Monks concerning the following question:
(Title updated per mscharrer)
O Monks - I fear may have spaghetti on my hands -- I hope not -- but am trying to limit my gaze (for now) to the part of the project in front of me -- if this small part proves impossible (for Perl? naah) I may have to address the larger mass of spaghetti and/or seek more help here. Anyhoo. What I have is an array of anonymous arrays over which I am iterating to get a result set (I'll be more explicit about this in a minute, in order to help it make sense). The problem is that I now need to DELETE the anonymous arrays in the result set, so I can iterate BACK over the (modified) array of arrays to check whether there is a second set of results that still meet the criteria. In short, I want to remove the records that satisfied the first run so I don't find them again. I looked at splice, but that seems to insist that one knows the indices or range of indices one wants to work on. Here, it's the contents of each anonymous array that are of interest. I'm thinking there may be a way to sort the array in such a way that the result set appears first (or last) and then be popped or pushed off, but ... honestly, my brain is tired and I would like PerlMonkish input on this. I'm operating at the limit of my Perl baby talk (this is a good thing, really. I am learning -- I hope -- but it is also tiring) and may need a hand stepping forward. To be more explicit about what this is doing (or why), the anonymous arrays contain three values: 0 is an x value, 1 is a y value, 2 is an ID number. x and y represent the coordinates of a single observation (referenced by the ID number) recorded by a CCD chip in a telescope. So the array of arrays represents all the observations recorded on that chip. I'm trying to find out whether the number of observations within strips of a given number of pixels exceed a set threshold value. Then I want to remove those results and see if there is a second strip that _still_ exceeds the threshold. The array of arrays look like this:
In this example set, there are a bunch of records between x=309 and x=338, enough to go over the threshold and cause the program to report them out. Now that I have found those, I want to delete them, so I don't find them again when I go back over the array of arrays. What is the best way to accomplish this? As always I appreciate any guidance, and apologize for the mental fatigue (and other weaknesses) that prompted me to post this at all ... Regards, G
Back to
Seekers of Perl Wisdom
|
|