in reply to Looping through a file

What does $ordnum look like? Does it look like a number or does it contain non-numeric characters? If the latter, you'll want to use a string comparison here:
if ($PARTS eq $ordnum) {
Also, note that the elements of the @PARTS array will have the terminating newline at the end, and this will interfere with string comparisons. To get rid of that, you can use:
chomp(@PARTS = <PARTS>);
Frankly, my preference is use a read loop:
while (<PARTS>) { chomp; if ($_ eq $ordnum) { ...
And finally, you can make your search a little more efficient by short-circuiting the loop when you've found a match:
for $PARTS (@PARTS) { if ($PARTS eq $ordnum) { # assuming 'eq' is correct here $found = 1; last; } }

Replies are listed 'Best First'.
Re^2: Looping through a file
by baixiaohu (Initiate) on Apr 15, 2008 at 20:23 UTC
    Thank you! Yes, there will alphanumeric, so I will use "eq" instead of "==".

    And yes, it's an array, not a hash as I seemed to indicate. Doy!

    If/when I figure it out, I'll post complete code for future reference.

    -Hu