(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:

( [48, 219, 11021], [72, 190, 11006], [203, 177, 11005], [301, 186, 11013], [309, 119, 11015], [309, 216, 11017], [309, 147, 11000], .... [343, 180, 10990], [346, 179, 10989], [451, 258, 11008], [838, 162, 11014] )

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


In reply to manipulating a matrix by chexmix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.