Don't quote the database handle.
(See below....)
>In order to avoid the lengthy connection procedure at every commit I
>would like the main program to connect once to the database upon startup
>and disconnect before it exited. This would mean handing the database
>handle to the individual object that I want to store, so that the object
>can use the existing handle and does not have to connect again itself
>(see code below).
>
>Unfortunately it does not seem to work, I get an error message telling
>me
>'Can't locate object method "prepare" via package
>"DBI::db=HASH(0x81d4d0c)" (perhaps you forgot to load
>"DBI::db=HASH(0x81d4d0c)"?) at FIGGED/element.pm line 59.'
>
>Am I doing something totally wrong here? I'm new to OO-perl so I don't
>know whether I just haven't grasped one of the intricacies or am trying
>to do something totally bananas. If this should not work at all, are
>there other ways to avoid having to connect each time the
>commit()-method is called?
>
>Thanks for any help in advance, here's the code:
>
>#########################
>#In the calling program:
>###########################
>use strict;
>use warnings;
>use DBI;
>my $dsn = "DBI:mysql:figged:localhost";
>my $user_name = "***";
>my $password = "***";
>my ($dbh, $param);
>my @arguments=@ARGV;
>
>($dbh = DBI->connect ($dsn, $user_name, $password, {RaiseError => 1 })) ||
>(print_error("CANNOT_OPEN_DATABASE"));
>
>#$the hash parampoints to is initialized in another subroutine
>
>my $obj=FIGGED::element->new("$$param{data}","$dbh");
>my $uoid=$obj->commit("$$param{data}","$dbh");
Don't quote the database handle, it'll stringify it into
something like "DBI::db=HASH(0x81d4d0c)" which is a string, not
a database handle.
Jon