in reply to Trouble with loops

To remove an element of an array you have to splice it out. This means you have to find the first index of the matching element:
for my $i (0..$#array) { if ($array[$i] eq "joby") { splice(@array, $i, 1); last; # exit loop - only interested in the first match } }
Your use of shift(@array) removes the first element of the array, not the element you are currently examining.