title: In Perl, how do I check for an undefined OR blank parameter?
body: <p>I have some code like the following:</p>
  <pre><code>if (not defined $id) {
      print &quot;Enter ID number: &quot;;
      chomp ($id = &lt;STDIN&gt;);
      exit 0 if ($id eq &quot;&quot;); # If empty string, exit.
  }
  if (not defined $name) {
      print &quot;Enter name: &quot;;
      chomp ($name = &lt;STDIN&gt;);
      exit 0 if ($name eq &quot;&quot;); # If empty string, exit.
  }
  if (not defined $class) {
      print &quot;Enter class: &quot;;
      chomp ($class = &lt;STDIN&gt;);
      exit 0 if ($class eq &quot;&quot;); # If empty string, exit.
  }
  </code></pre>
  <p>I'd like to be able to potentially pass only some of them (e.g., name and class, but not ID), passing blanks for the unpassed ones, so I thought the following would work:</p>
  <pre><code>if (not defined $id || $id eq &quot;&quot;) {
      print &quot;Enter ID number: &quot;;
      chomp ($id = &lt;STDIN&gt;);
      exit 0 if ($id eq &quot;&quot;); # If empty string, exit.
  }
  </code></pre>
  <p>But it doesn't seem to work if I pass, e.g., the following:</p>
  <pre><code>perl &quot;myperlroutine.pl&quot; &quot;&quot; &quot;Mickey Mouse&quot; &quot;Entry&quot;
  </code></pre>
  <p>The command window (I'm running this on Windows) briefly appears and then immediately disappears.</p>
  <p>Am I missing something obvious?</p>