my $suffix = 'FROM table WHERE blah blah'; my ($to_be_deleted) = $dbh->selectrow_array( "SELECT count(*) $suffix" ); $dbh->do( "DELETE $suffix" );