From a quick scan, if the user presses the <enter> key, s?he will enter a newline ("\n"), which Perl will interpret as 0 in the numerical equality test, and 0 is less than 1.0, so the result for the first part of condition 3 is "TRUE." The second part of the test for condition 3 is ill-formed, in that "Cust1"||"Cust2" is legitimate, albeit useless, Perl, which will return true if "Cust1" or "Cust2" is true, which they are given Perl's notion of truth. You should probably rewrite that part of the test to
$bak_id eq 'Cust1' or $bak_id eq 'Cust2'
or use a regex:
$bak_id =~ /^Cust[12]$/
in both places it occurs. Actually, since you're using the same sort of test twice, I'd move the logic into a named sub against the inevitable day when the customer (instructor?) generalizes Cust[12] to /Cust[0-9]+/.
Since this test is before the tests to return to main menu, it never gets there.
Addendum
There are many ways to code the logic you need to validate input, including some modules. My general preference, in Perl, is to assume all inputs from stdin are strings, and postpone any numerical tests until after I've ensured myself that the data actually represent legitimate numbers.
Information about American English usage here and here. Floating point issues? Please read this before posting. — emc
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.