Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
My question to you perl experts is this: would it be possible to assign a particular result if it doesnt find a match? Would it be better to use something else besides the matching operator? Is there an operator to state if nothing matches? I have a list of users stored in an array called @names(20 names) in this format "MANDERSON/Anderson MikeD|MikeD.Anderson\\". @cdwv_list has a list of 10 names stored with this format "MANDERSON". Here is an example of the code:
Thanks in advance.... Thomasfor ($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"; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: To Pattern Match or not to Pattern Match
by Roy Johnson (Monsignor) on Mar 04, 2005 at 00:05 UTC | |
by Anonymous Monk on Mar 04, 2005 at 00:35 UTC | |
Re: To Pattern Match or not to Pattern Match
by Zed_Lopez (Chaplain) on Mar 04, 2005 at 00:15 UTC | |
Re: To Pattern Match or not to Pattern Match
by sh1tn (Priest) on Mar 04, 2005 at 00:17 UTC | |
Re: To Pattern Match or not to Pattern Match
by Roy Johnson (Monsignor) on Mar 03, 2005 at 23:57 UTC | |
Re: To Pattern Match or not to Pattern Match
by mlh2003 (Scribe) on Mar 03, 2005 at 23:56 UTC | |
by Anonymous Monk on Mar 04, 2005 at 00:14 UTC |
Back to
Seekers of Perl Wisdom