Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: To Pattern Match or not to Pattern Match

by mlh2003 (Scribe)
on Mar 03, 2005 at 23:56 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-18 19:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found