Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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.

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?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2022-01-28 00:39 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (72 votes). Check out past polls.