title: Using Perl ? bind inside single quotes
body: <p>This scripts works fine for all commands that don't require % wildcards. When I attempt to wrap the ? in %?% which producing a bind error. Also I have tried adding %value% to the argument when running the script and it also producing the same error. Is there a way to substitue an argument into a SQL DBI command in perl?</p>
  
  <p>Thanks, in advance.</p>
  
  <pre><code>#!/usr/bin/perl
  
  use DBI;
  use Text::Diff;
  use File::stat;
  use Fcntl ':flock';
  
  open (LOCK_FH, $0) || die "$0 for lock: $!\n";
  flock (LOCK_FH, LOCK_EX|LOCK_NB) || die "$0 already running\n";
  
  $BINDVAR = $ARGV[0];
  $dbname = "COnnectionDetailsHere";
  $un = "username";
  $pw = "password";
  
  my $dbh = DBI-&gt;connect ( $dbname, $un, $pw, { PrintError=&gt;1, RaiseError=&gt;1, AutoCommit=&gt;0, LongReadLen=&gt;5056}) or die "Couldn't connect to DB: " . DBI-&gt;errstr;
  
  $sql = &lt;&lt;SQL
  
  select * from foo where bar like '%?%' '?'
  
  SQL
  ;
  
  $stm = $dbh-&gt;prepare($sql) or die "SQL failed to prepare $DBI::errstr\n";
  
  $stm-&gt;bind_param(1,($BINDVAR));
  
  $stm-&gt;execute() or die "Couldn't execute the statement: " . $stm-&gt;errstr;
  </code></pre>