Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Sort your data in the database. This will be faster. It also scales better when you just want part of the result set, because you can use LIMIT (or whatever your DB supports).
    • Yeah, what autarch said.

      This is why gave up Class::DBI – it very nearly forces you to do on the Perl side what should be done at the SQL level because it makes it way too difficult to do the latter. First you run into a wall of no documentation, then you often have to put up with annoying verbiage. After reading the source for 15 minutes, I think the following will do what you need:

          all_by_kwalitee => 'SELECT __ESSENTIAL__ FROM __TABLE__ ORDER BY kwalitee',
      my @distros = CPANTS::Distro::Kwalitee->sth_to_objects( 'all_by_kwalitee' );

      Note that sth_to_objects() is not documented anywhere. The code should work, but I cannot tell since I’m not going to spend another 15 minutes setting up all the knobs and handles that testing Class::DBI code requires. If it does not work, the least-effort approach will require more red tape. Compare to plain DBI to get an AoH, which is clearly documented and took me 40 seconds to write:

      my $distros = $dbh->selectall_arrayref( 'SELECT * FROM kwalitee ORDER BY kwalitee', { Slice => {} } );

      Plain DBI is at times crufty, but at least it doesn’t get in your way. As a bonus, it has much less overhead. Class::DBI is seductive, and will whisper in your ear that you that you don’t need to get your hands dirty with all that SQL, but in practice I’ve found it fails to deliver. Last not least, Class::DBI’s dependencies are legion.