in reply to Re: Undesired array growth
in thread Undesired array growth

Good catch on the backwhack, thanks! Fixed that typo, but the problem is still continuing. =/ I'd love to find a simpler way to do it, but this is the best way I could come up. Granted, I do have a tendency to over-complicate things.

So at this point in the script, the data is stored in a 3d array. @meta holds the pages, each page holds an array of lines, and each line points to an array of 3 values: Field Name, Field Type, and Field Details. Since it is originally raw text pulled from a pdf, each line is not necessarily a field's full information. Some field names are long enough to be split into two lines, and some of the field details can take up to 15 or 20 lines, but the field type is always only one line.

The script uses that to check if the line below the current one is the beginning of another field definition (field 0,1,2 defined) or a continuation of the current one (1 undefined, either/both 0/2 defined). If the latter it concats the lower line values onto the current line ($line_num) and then removes the lower line($line_num+1).

I tried using splice and undef, but that just leaves $line_num+1 undefined. I was hoping to get around that with sub del, so it could just concat and loop until a new definition (0,1,2 defined) was next, and then move down and repeat. It works great... until the end when the array of lines on the page starts growing.