Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: To Pattern Match or not to Pattern Match

by mlh2003 (Scribe)
on Mar 03, 2005 at 23:56 UTC ( #436414=note: print w/replies, xml ) Need Help??


in reply to To Pattern Match or not to Pattern Match

In your else block, you need to add 'last;' to exit the inner loop and go to the next element in the outer loop.
else { print "Name does not exist\n"; last; }
That should prevent that line from printing 10 times.
--------------------
mlh2003

Replies are listed 'Best First'.
Re^2: To Pattern Match or not to Pattern Match
by Anonymous Monk on Mar 04, 2005 at 00:14 UTC
    I think the problem here is that it loops through the 1st 10 names in @names and since none of those 10 matches it prints out "Name does not exist" 10 times. I need it to loop through all 20 strings in @names and if it doesnt find a match then print "Name does not exist" only once, buts only my guess.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://436414]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2021-10-24 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?