title: Perl - If table does not exist
body: <p>I'm currently using the following which works but throws an error every time the table is created (as it is first trying to insert into a db which does not exist and returning false).</p>
  
  <pre><code>$result = $dbh-&gt;prepare("INSERT INTO `". $host ."` (URL) VALUES ('$href')");
  if( ! $result-&gt;execute() ){
      $result = $dbh-&gt;prepare("CREATE TABLE `" . $host . "` ( `ID` INT( 255 ) NOT NULL AUTO_INCREMENT , `URL` VARCHAR( 255 ) NOT NULL , PRIMARY KEY ( `ID` )) ENGINE = MYISAM ;");
      $result-&gt;execute();
      print "Host added: " . $host . "\n";
  }
  </code></pre>
  
  <p>Could someone let me know of a more efficient way of completing this task?</p>
  
  <p>EDIT - Bind</p>
  
  <pre><code>$result = $dbh-&gt;prepare("CREATE TABLE `?` If NOT EXISTS ( `ID` INT( 255 ) NOT NULL AUTO_INCREMENT , `URL` VARCHAR( 255 ) NOT NULL , PRIMARY KEY ( `ID` )) ENGINE = MYISAM ;");
              $result-&gt;execute($host);
              $result = $dbh-&gt;prepare("INSERT INTO `?` (URL) VALUES ('?')");
              $result-&gt;execute($host, $href);
              print "Host added: " . $host . "\n";
  </code></pre>
  
  <p>is this correct?</p>