in reply to Detecting a Null or Enter key
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
or use a regex:$bak_id eq 'Cust1' or $bak_id eq 'Cust2'
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.$bak_id =~ /^Cust[12]$/
|
|---|