my $count = 0; for(@protected){ if($_ eq $user[0]){ sock(...blah blah blah...); last; } $count++; } print("$user[0] was found at ".$count+1." in the list.\n");