Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Wow, truly the monks are wise and patient. Thanks for the great advice.

Yes, I had some sense that goto might be a little hacky, but I didn't know how to use subroutines. Obviously, they are the magic answer I needed. Also, I did use strict and use warnings while I was working on this, but after I knew it would work, I didn't bother pasting them in here--why? Who knows; however, I now see the error of my ways.

Looking at your for loop, I have a question. How does this handle the situation in which the player does successfully guess the answer in under ten tries? Since you have set the loop to run ten times, it looks like it will print "you have x guesses left" and wait for guess input even after you have won the game. I have just run the code and seen that this is not the case, but I can't figure out why. (Also, it looks like the "guesses left" line needs to be removed from the if statements, since you have put it at the top of the for loop. But this is a simple matter.)

Here is another question: why do I have to chomp $again, but not chomp $guess?


In reply to Re^2: Number Guess by cryptoquip
in thread Number Guess by cryptoquip

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-16 23:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found