The DBI::Profile docs say that these are all equivalent:
$h->{Profile} = {};
$h->{Profile} = "DBI::Profile";
$h->{Profile} = "2/DBI::Profile";
$h->{Profile} = 2;
However, the first fails to setup the default Path selection of 2 and the
second one causes an error:
Argument "DBI::Profile" isn't numeric in numeric lt (<) at blib/lib/DBI/Profile.pm
line 490.
Attached is a patch which fixes the problems.
-sam
--- Profile.pm.old Thu Oct 3 19:02:13 2002
+++ Profile.pm Thu Oct 3 19:13:20 2002
@@ -482,8 +482,20 @@
# assigned to the Profile attribute. For example
# dbi:mysql(RaiseError=>1,Profile=>4/DBIx::MyProfile):dbname
# This sub works out what to do and returns a suitable hash ref.
+
+ my ($path, $module, @args);
- my ($path, $module, @args) = split /\s*\/\s*/, $arg, -1;
+ # parse args
+ if ($arg =~ m!/!) {
+ # it's a path/module/arg/arg/arg list
+ ($path, $module, @args) = split /\s*\/\s*/, $arg, -1;
+ } elsif ($arg =~ /^\d+$/) {
+ # it's a numeric path selector
+ $path = $arg;
+ } else {
+ # it's a module name
+ $module = $arg;
+ }
my @Path;
if ($path) {
@@ -493,10 +505,13 @@
push @Path, DBIprofile_MethodName if $path & 0x04;
push @Path, DBIprofile_MethodClass if $path & 0x08;
@Path = reverse @Path if $reverse;
+ } else {
+ # default Path
+ push @Path, DBIprofile_Statement;
}
if ($module) {
- if (eval { require $module }) {
+ if (eval "require $module") {
$class = $module;
}
else {