title: Perl: Accept User Input in if-else statement
body: <p>I am accepting User Input in an If-Else block. Check Code:</p>
  
  <pre><code>if ( $svr == 1 ) {
      print "Enter Datbase Name\n";
      my $db = &lt;&gt;;
      chomp($db);
  } elsif ( $svr == 2 ) {
      print "Enter Data Source Name (DSN)\n";
      my $db = &lt;&gt;;
      chomp($db);
  }
  </code></pre>
  
  <p>When I am referring to $db in a later statement, I am getting the following error:</p>
  
  <p>"Use of uninitialized value $db"</p>
  
  <p>This is the statement in which I am using $db that is  causing the error:</p>
  
  <pre><code>my $data_source = 'DBI:mysql:' . $db . ':' . $host;
  </code></pre>
  
  <p>Please help</p>