my $pattern = qr/\b(?:create|drop|delete|update|insert)\b/i; # open a database connection here (using Sybase::DBD) and # create a statement string to execute $sth=$dbh->prepare("@sqlstatement"); $sth->execute; while ($data = $sth->fetchrow_arrayref()) { next if($data->[10] =~ /tempdb/i); if ($date->[13] =~ $pattern) { print "$data->[3] $data->[9] $data->[10] $data->[13]\n"; } }