I don’t really understand what this code is trying to do, so I’ll just offer some observations:
The code as given does not compile. This line:
print "OKAY: found the column as "class"\n";
needs to be:
print "OKAY: found the column as \"class\"\n";
with the inner double-quote characters backslashed.
You should always — yes, always! — begin each script with:
— and never comment them out again!
I suspect the script’s main problem is with the next statement on the 6th-last line. This ends the current iteration of the innermost loop, but as it’s the last statement within that loop, it currently does nothing. Perhaps you meant last? Or next LABEL; where LABEL refers back to a previous (i.e., outer) loop? See next and last in Perl documentation.
Hope that helps,
Athanasius <°(((>< contra mundum