title: Perl: CGI module - passing param() as parameters to subroutines
body: <p>Question about using the Perl CGI module:</p>
  
  <p>Let's say I have a sub called foo that accepts two parameters defined as follows:</p>
  
  <pre><code>sub foo {
     local($a, $b) = @_;
     print "a= [$a]";
  }
  </code></pre>
  
  <p>In my main routine, I take some form parameters and pass them to foo like this:</p>
  
  <pre><code>use CGI;
  $cgi = CGI-&gt;new;
  foo($cgi-&gt;param('field1'), $cgi-&gt;param('field2'));
  </code></pre>
  
  <p>If the form did not pass in a value for field1, (in my case, a SELECT field called field1 with no values to choose from was used), the sub foo sets $a to the value that was passed in $cgi->param('field2'), which was a non-empty value.</p>
  
  <p>Can someone help me understand why this happens and why $a isn't simply a blank ('') value and $b = the value sent in from $cgi->param('field2')?</p>
  
  <p>I'm sure there's a logical reason, but I'm not a Perl pro so I'm sure it's something I've yet to learn or understand about Perl.</p>
  
  <p>Thanks in advance!</p>