in reply to To Pattern Match or not to Pattern Match

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.

Replies are listed 'Best First'.
Re^2: To Pattern Match or not to Pattern Match
by Anonymous Monk on Mar 04, 2005 at 00:35 UTC
    Roy Johnson, thanks for your help. The code works exactly like what I needed. Thanks to everyone else that responded. If I had any sort of pts or anything to give you guys I would. I greatly appreciate the help. --Thomas