Try #2: I just realized what you're expecting it to do. You have nested loops, and your test is inside the innermost loop. So it's going to run 20 times (inner loop) for
each of the 10 names (outer loop).
The "operator to state if nothing matches" might be grep. Something like:
for my $user_id (@cdwv_list) {
my ($names) = grep(/^\Q$user_id/, @names);
if ($names) {
($name) = $names =~ /\/([\w\s]+)\|/;
}
else {
print "$userid does not exist in name list\n";
}
}
Caution: Contents may have been coded under pressure.