Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Checking username and password but cant break whileloop!

by NetWallah (Abbot)
on Nov 09, 2012 at 16:11 UTC ( #1003177=note: print w/replies, xml ) Need Help??


in reply to [SOLVED] Checking username and password but cant break whileloop!

You need to change your logic such that the "does not match" message is printed AFTER the WHILE loop completes.

This means, you need a flag inside the while loop that determines whether or not a match was found.

Typically, this would be something like a $match_count, which initializes to zero, and is incremented on each match.
This counter could also be used to exit the loop early, if a match is found (using the 'last' verb).

At the end of the loop, if it is still zero, you print the message.

             "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius

  • Comment on Re: Checking username and password but cant break whileloop!

Replies are listed 'Best First'.
Re^2: Checking username and password but cant break whileloop!
by jaffinito34 (Acolyte) on Nov 09, 2012 at 16:18 UTC

    Genius

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003177]
help
Chatterbox?
[Corion]: Eily: Sure - if you force both things into stringy things, then you break that magic. But that would also mean that you changed the expression, as now $x = 0.00 will be true instead of false as it were before
[Corion]: Ah no, at least in my feeble experiments that doesn't change the meaning
[Corion]: We sell sanity in small packages ;)
[Eily]: oh, boolean context uses the "" overload if no bool overload has been defined
[Eily]: (I wondered if overloading bool was actually necessary)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2017-07-27 13:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (414 votes). Check out past polls.