#!/usr/bin/perl -w use strict; use DBI; my $thing = shift || 'muttley'; my $dbh = DBI->connect( 'dbi:mysql:diana', '$username', '$password' ) || die "DB connection not made - $DBI::errstr\n"; $thing = $dbh->quote("%$thing%"); my $sql = qq{select pkey from t_plusplus where pkey like $thing}; my $sth = $dbh->prepare($sql); $sth->execute; while (my $key = $sth->fetchrow_array) { print $key."\n"; } $sth = undef; $dbh->disconnect; exit 0;