We are trying to build an API to support commit() and rollback() automatically, so that we don't have to bother with it anymore. By researching, we have found that using eval {}
is the way to go.
For eval {}
to know what to do, I have thought of giving the API an array of functions, which it can execute with a foreach
without the API having to intepret anything. However, this function might be in a different package.
Let me clarify with an example:
sub handler {
use OSA::SQL;
use OSA::ourAPI;
my @functions = ();
push(@functions, OSA::SQL->add_page($date, $stuff, $foo, $bar));
my $API = OSA::ourAPI->connect();
$API->exec_multi(@functions);
}
The question is: Is it possible to execute the functions in @functions
inside of OSA::ourAPI
, even if ourAPI has no use OSA::SQL
. If not, would it be possible if I use an array reference instead of an array, given that the pointer would point to the known function inside of the memory?
Note: This is the basic idea that we want to base the more complex final version on.