title: How can I set a default value for a Perl variable?
body: <p>I am completely new to Perl. I needed to use an external module HTTP::BrowserDetect. I was testing some code and tried to get the name of the OS from os_string method. So, I simply initialized the object and created a variable to store the value returned. </p>
  
  <pre><code>my $ua = HTTP::BrowserDetect-&gt;new($user_agent);
  my $os_name = $ua-&gt;os_string();
  
  print "$user_agent $os_name\n";
  </code></pre>
  
  <p>there are some user agents that are not browser user agents so they won't get any value from os_string. I am getting an error <code>Use of uninitialized value $os_name in concatenation (.) or string</code></p>
  
  <p>How do I handle such cases when the $os_name is not initialized because the method os_string returns undef (this is what I think happens from reading the module source code). I guess there should be a way to give a default string, e.g. No OS in these cases.</p>