Well, progress.
Initially I got this:
$ ./testdb
Can't locate DBI.pm in @INC (@INC contains: /usr/perl5/site_perl/5.12/sun4-solaris-64int /
usr/perl5/site_perl/5.12 /usr/perl5/vendor_perl/5.12/sun4-solaris-64int /usr/perl5/vendor_
perl/5.12 /usr/perl5/5.12/lib/sun4-solaris-64int /usr/perl5/5.12/lib .) at ./testdb line 3 .
BEGIN failed--compilation aborted at ./testdb line 3.
Then after pkg install pkg:/library/perl-5/database (worked!), I now get
# ./testdb
install_driver(mysql) failed: Can't locate DBD/
mysql.pm in @INC (@INC contains: /usr/perl5/site_perl/5.12/sun4-solaris-64int /usr/perl5/site_perl/5.12 /usr/perl5/vendor_perl/5.12/sun4-solaris-64int /usr/perl5/vendor_perl/5.12 /usr/perl5/5.12/lib/sun4-solaris-64int /usr/perl5/5.12/lib .) at (eval 3) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge.
at ./testdb line 12