for ($j = 0; $j < @cdwv_list; $j++) { $user_id = $cdwv_list[$j]; foreach $names(@names) { if ($names =~ $user_id) { #if match I want it to grab name $names =~ /\/([\w\s]+)\|/; $name = $1; } #So what do I put here or somewhere else if #the 1st $name doesnt match any of the 10 #users from @cdwv_list? I tried: else { #But it only prints this 10 times #even thought only 1 name doesnt #match between the two list print "Name does not exist\n"; } } }