Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Your script causes my perl (AS 5.14) to throw multiple messages... had you included use strict (as you should have), it would have filled the screen with your problems. But these are what you should have told us about, at a minimum, rather than tossing them into the "not working" garbage pile:

Unquoted string "easy" may clash with future reserved word at D:\_Perl +_\pl_test\977910.pl line 6. Unquoted string "hard" may clash with future reserved word at D:\_Perl +_\pl_test\977910.pl line 9. Found = in conditional, should be == at D:\_Perl_\pl_test\977910.pl li +ne 13. Unquoted string "easy" may clash with future reserved word at D:\_Perl +_\pl_test\977910.pl line 13. Unquoted string "hard" may clash with future reserved word at D:\_Perl +_\pl_test\977910.pl line 16. Found = in conditional, should be == at D:\_Perl_\pl_test\977910.pl li +ne 20. Found = in conditional, should be == at D:\_Perl_\pl_test\977910.pl li +ne 47. Name "main::RNG" used only once: possible typo at D:\_Perl_\pl_test\97 +7910.pl line 21. D:\_Perl_\pl_test\977910.pl syntax OK
  • = makes an assignment; you want == in your conditional to test for (numeric equality or -- in this case -- eq or a regex to test the alpha entry you invite.
  • BUT even when you correct your ifs, you still have work to do. The Monastery is rife with examples of collecting input, so with the exception of the implicit hint there, learning how to fix it is yours to do.
  • Among other things, just using a more idiomatic way to deal with input won't make your code "good;" you also need to add some error handling: what should your script do if the user merely hits enter when asked for a name?
  • The gotos are utterly unnecessary in this script. You can take them out and have execution simply fall thru from one named section to another.
  • Your lines 5-17 attempt to execute before a value is assigned to $diff. (Think reordering your code or stuffing those lines into a sub, called after the other input is received).

Try another iteration... show us how you solved these.


In reply to Re: SImulation of an Inventory. by ww
in thread SImulation of an Inventory. by Dipseydoodle

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 chanting in the Monastery: (4)
As of 2024-04-25 07:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found