Short answer: use strict and warnings, even just "to get it working." Off the cuff I don't think that will illustrate the problem here (logical error, not syntactical), but it won't hurt.

But your input is stored into $input2 which is checked against a number (you don't need the 'int 1' bit, it can be just 1). Then you have a conditional:
if($input2 ne NULL || $input2 ne " ")
At this point $input2 has not been reset by new user input. So if they choose anything, $input2 will most definitely be ne " ". Which means you recursively call your choice subroutine. (Hint: This really isn't what you want)

So you need to clean things up a bit. I'd suggest something like the following pseudo-code:

good_input = 0; while (not good_input) { display menu get user input if user input == 1 do stuff for choice one set good_input true elsif user input == 2 do stuff for choice two set good_input true # continue processing choices with elsif, # but the last bit should be the default # case: else display error message }

This is simplistic in its approach, I'm sure other monks have a better idea or style. But it's fairly easy to understand, I think.

Also, as Joost suggested, do some cleanup of the code with perltidy. On top of that, you could narrow down the scope of future questions -- find what it is that's going wrong, and write the shortest code snippet you can to illustrate the problem. You already know the basic area -- it's running into an infinite loop on the choice menu.


In reply to Re: Adding a Users data by Nkuvu
in thread Adding a Users data by Snowman11

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.