use warnings; use strict; use feature 'say'; use DBI; my $dbh = DBI->connect( "DBI:mysql:database=testing;host=127.0.0.1", $ENV{USER}, 'barfoo', { RaiseError => 1, AutoCommit => 1 }); $dbh->do('DROP TABLE IF EXISTS texts'); $dbh->do(<<'ENDSQL'); CREATE TABLE texts ( string VARCHAR(256) ); ENDSQL $dbh->do('INSERT INTO texts (string) VALUES ("/a/b/c");'); # --- my $string = '/a/b/c'; my $req = qq{ SELECT * FROM `texts` WHERE `string`=?}; my $sth = $dbh->prepare($req); my $row = $sth->execute($string); say "row = $row"; # --- my $sth2 = $dbh->prepare( q{ SELECT * FROM texts WHERE string LIKE '%/a/b/c%' }); $sth2->execute; say "row = $row";