IMO, you need to use strictures, after which the test for empty input should be performed first ... and then go on to process the entered data e.g.
#!/usr/bin/perl use warnings; use strict; local ($bak_id)=shift; local ($acc_bal)=shift; $bak_id=<STDIN>; $acc_bal=<STDIN>; chomp ($bak_id); print "Returning to MM\n", exit 0 unless $bak_id; . . .
Even better, IMO, would be to use a hash-based dispatch table keyed on (what was previously) $bak_id expressed as a regex e.g.
#!/usr/bin/perl use warnings; use strict; my %dispatch = ( '' => sub { print "Returning" ; exit }, 'BOTH' => sub { my $acc_bal = shift; . if ($acc_bal < 1.0) { . . } else { . . } }, 'Cust1|Cust2' => sub { my $acc_bal = shift; . if ($acc_bal < 1.0) { . . } else { . . } }, ); my ($bak_id, $acc_bal); while (1) { chomp($acc_bal = <STDIN>); foreach my $re (keys %dispatch) { next unless $acc_bal =~ /^(?:$re)$/; &{ $dispatch{$_} }(chomp <STDIN>); } } . .
or some such.

Afterthought: I've only just realised that you don't allow a value of 0 - it's either less or grater than 0 ?

A user level that continues to overstate my experience :-))

In reply to Re: Detecting a Null or Enter key by Bloodnok
in thread Detecting a Null or Enter key by John007

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.