The thousand and one reasons to love Perl: [4] DBI
DBI is the Perl database interface. Like all modern database interfaces, DBI consists of a database-independent API and specific drivers for the various databases. This means that you can write code for Oracle, SQLite, MySQL, PostgreSQL or any other supported SQL database management system without having to learn a new interface every time. Theoretically, this also allows you to switch your application to another DBMS just by loading a different driver (without changing code). This does not work in the real world, however, as each DBMS has its unique features (which you can hardly avoid making use of) and SQL flavour.
Java people seem to think verbosity a virtue, and this also shows in JDBC (the Java database interface). Perl DBI is much more concise. Compare the following two fragments that do the same thing (a one-row database query).
Java version
PreparedStatement sql = conn.prepareStatement(
"select count(*), sum(price) from sales"
+ " where category = ? and trunc(sales_date, 'Month') = ?"
+ " group by trunc(sales_date, 'Month')"
);
sql.setString(1, category);
sql.setString(2, month);
ResultSet rs = sql.executeQuery();
int count, sum;
if (rs.next()){
count = rs.getInt(1);
sum = rs.getInt(2);
}
rs.close();
sql.close();
Perl version
my ($count, $sum) = $conn->selectrow_array ( q[
select count(*), sum(price) from sales
where category = ? and trunc(sales_date, 'Month') = ?
group by trunc(sales_date, 'Month')
], {}, $category, $month);



