title: How do I check for an empty scalar in Perl?
body: <p>How do I check for an empty scalar in perl? If I have no <code>$list</code>, I do not want to send an email. </p>
  
  <p>Can I check for empty message in the send_email routine or do this outside?</p>
  
  <p>I have a query that uses <a href="http://search.cpan.org/~jdb/Win32-OLE-0.1709/lib/Win32/OLE.pm" rel="nofollow">Win32::OLE</a>.</p>
  
  <pre><code>my $servSet = $wmiObj-&gt;ExecQuery("SELECT * FROM Win32_Service WHERE DisplayName LIKE 'ServiceNameHere%'", "WQL",  wbemFlagReturnImmediately | wbemFlagForwardOnly);
  </code></pre>
  
  <p>I'm looping through it here and building a list <code>$list</code></p>
  
  <pre><code>foreach my $serv (in $servSet) {
      next if $serv-&gt;{started}; 
      my $sname  = $serv-&gt;{name};
      my $sstate = $serv-&gt;{started};
      my $ssmode = $serv-&gt;{startmode};
      $list .= "Service: $sname  - $sstate - $ssmode\n";  
   }
  </code></pre>
  
  <p>I use the $list to send as body of the email:</p>
  
  <pre><code>sub send_email {
  ...
  ..
  $smtp-&gt;datasend($list);
  ..
  .                        
  }
  </code></pre>