in reply to Re^4: Seeking help with Looping problem
in thread Seeking help with Looping problem

That's because you defined $ordernum in this block:
if ($ordertype eq "HM")
But then tried to use that variable outside of the block. You need to change the scope of the variable since the movement code block was relocated.