Your question is not clear enough for me. It would be useful if I could run your code to try to reproduce your results, but the code does not compile. Try to reduce your code to be a stand-alone script, and provide a small sample of what your input file contains. Refer to
GrandFather's excellent node:
I know what I mean. Why don't you?.
I suspect you have the comparison operators confused. To compare numeric values, use ==; to compare strings, use eq.
You probably want to change:
if ($found eq 0){
to:
if ($found == 0){
If you are trying to compare 2 strings here, use eq:
if ($PARTS == $ordnum) {