So what's new with a recent DBI module? First profiling. Only by setting the DBI_PROFILE environment variable, DBI will display many useful informations about the time taken by your queries.

Then we have a better support of Unicode. For example it's now possible to compare strings as characters, not as bytes. Another improvement is the ability to fetchall_hashref. Instead of a loop on fetchrow_hashref, fetch all rows in a single operation. To make things even simpler, selectall_hashref does prepare, execute and fetchall_hashref all at once.

# convert hash key name to lowercase
$dbh->{FetchHashKeyName} = 'NAME_lc';
 
$sth = $dbh->prepare("SELECT foo, bar, baz FROM table");
$sth->execute;
$hash_ref = $sth->fetchall_hashref( [ qw(foo bar) ] );
print "For foo 42 and bar 38, baz is $hash_ref->{42}->{38}->{baz}\n";
 
# Even simpler, with selectall_hashref
$hash_ref = $dbh->selectall_hashref(
    "SELECT foo, bar, baz FROM table",
    [ qw(foo bar) ]
);
print "For foo 42 and bar 38, baz is $hash_ref->{42}->{38}->{baz}\n";

Function execute_array executes a prepared statement as many times as it can find values in the first bound array.

my $query = '
INSERT
  INTO fruits
  (name, color)
  VALUES''
  (?, ?)
';
 
my $sth = $dbh->prepare($query);
 
my @fruits = (
    {
        name  => 'banana',
        color => 'yellow',
    },
    {
        name  => 'cherry',
        color => 'red',
    },
    {
        name  => 'orange',
        color => 'orange',
    },
);
 
my @fruit_names  = map { $_->{name}  } @fruits;
my @fruit_colors = map { $_->{color} } @fruits;
 
my $tuples = $sth->execute_array(
   \@fruit_names,
   \@fruit_colors,
);

Note that if Autocommit is turned off, this "way to do it" should be as fast as a single multiple insert. In my opinion, the fastest way to do it is to make a single multiple insert query, when your DBMS supports this feature. I'll benchmark several ways to do it later.

installed_versions function gives a very handy set of informations on your installed DBI drivers:

$ perl -MDBI -e 'DBI->installed_versions'
  Perl            : 5.008004    (i386-linux-thread-multi)
  OS              : linux       (2.4.27-ti1211)
  DBI             : 1.52
  DBD::mysql      : 3.0006
  DBD::Sponge     : 11.10
  DBD::Proxy      : 0.2004
  DBD::File       : 0.35
  DBD::ExampleP   : 11.12
  DBD::DBM        : 0.03

Simon CozensMichael Schwern's talk was replaced by two talks from Simon Cozens (see photo). The first one was about hashes. How and why using them. I didn't learn any technical stuff there but Simon is a very good talker. His presentation was clear, even slides were very beautiful, which is quite rare in the world of programmers. His second talk was about "How to make people using Perl?". Simon explains that people programs to get things done, easily and fast. This is exactly what Perl let programmers do. As an illustration, Simon gave a few examples of Perl programs he had written : a wireless network security tool, Memories a photo sharing solution (which of course interested me a lot), a newsletter system based on POD syntax and a support database system.

Next talk was another one from Dave Cross. Dave gives his feelings about Object Relationnal Mapping (ORM). Dave is not against ORM, but he wanted to complain about current ORM implementations. Here is a list of complaints:

  • too much typing
  • breaks the DRY rule (Don't Repeat Yourself)
  • not clever enough
  • ORM toolkits should automate class generation
  • ORM toolkits should let use defined data types for columns, not only scalars

Léon Brocard In the afternoon, I really wanted to follow Tim Bunce's talk "Advanced Perl DBI". But the Camel room was full. I joined Léon Brocard's talk "what was that again" (see photo). Léon talked about his recipes websites. Léon has a lot of recipes (nearly 200,000) and must find some ways to find the recipe he wants. Léon uses Kinosearch, tagging, tag clustering. On each recipe, he shows the related recipes, which let you wander until ou find the right recipe.

Later in the afternoon, I attended the CPAN6 presentation by Mark Overmeer. CPAN6 is for CPAN what Perl 6 is for Perl. Some kind of a full rewrite. The problem with current CPAN is that it was designed 10 years ago. In my opinion, the major improvement for CPAN6 will be the "approval workflow". Before publishing a new version of a module you will have to be signed by people involved in the module. You won't just do it when you want.

I missed another talk from Dave Cross where he explains his feelings about the position of Perl among other programming languages. I've read his slides and talked with some attenders. What I've understood is that Perl is not a buzz word anymore as Ruby can be today, but Perl 6 should be in a short term future. Perl lacks of marketting. Perl is only known by hackers and shared among hackers. If we want Perl to be known by management, we need Perl to be quoted in management magazines, just as Java or dotNet is.

Diner Birmingham.pm organisers managed to find a room for 200 people (see photo). We had a nice dinner in what seemed to be a wedding celebration room. The food was a mix of Indian dishes. It was really good, very spicy for a french guy like me, but I liked it. I've met Erwan, another frenchy, working with Perl in Sweden. He was glad to speak french and we talked about our work and different ways of life between France and Sweden.

Links:

The YAPC::Europe 2006 report goes on Day 3