title: How do I check if a Perl scalar variable has been initialized?
body: <p>Is the following the best way to check if a scalar variable is initialized in Perl, using <code>defined</code>?</p>
  
  <pre><code>my $var;
  
  if (cond) {
      $var = "string1";
  }
  
  # Is this the correct way?
  if (defined $var) {
      ...
  }
  </code></pre>