select Just use SQL::Abstract to generate SQL, so watch SQL::Abstract for options. For example: my fields => ['col1', 'col2'], my $where => { user => 'nwiger', priority => [ { '=', 2 }, { '>', 5 }, ], }, my $order => ['col1', {-desc => 'col2'}] select $table, $fields, $where, $order, sub { my ($row) = @_; $row->each(sub{ my ($colname, $colvalue) = @_; }) }