title: How to suppress arbitrary warn/error messages from DBI?
body: <p>code:</p>
  
  <pre><code># A:
  $dbh-&gt;do(qq/insert into foo(cl) values('test')/);
  # B:
  $dbh-&gt;do(qq/insert into foo(cl) values('test')/) or warn $dbh-&gt;errstr;
  # C:
  eval { $dbh-&gt;do(qq/insert into foo(cl) values('test')/); };
  warn "error : $@ " if $@;
  </code></pre>
  
  <p>All would output :</p>
  
  <pre><code>DBD::mysql::db do failed: Duplicate entry 'test' for key 'cl' at a.pl line 9.
  </code></pre>
  
  <p>I dont want this arbitrary warning/error message send to stderr. I'd like use <code>warn $dbh-&gt;errstr</code>.</p>
  
  <p><code>perl a.pl 2&gt;/dev/null</code> would suppress the error message, but I want to know how to do this in script?</p>