sub database_action { my $self = shift; my $q = $self->query(); my $me = "$self->database_action()"; # Used in result messages for debugging my @page = split('\.', $q->param('page')); # Resource requested, for example, page='section.inventory.add_record' my $database_name = $page[$#page - 1]; # The second-last page element is the database my $database_action = $page[$#page]; # The resource as well as the method # Do some things here relating to the run mode my $pkg = "My::SomePath::$database_name"; eval "require $pkg;"; if ($@) { $result = "

$me: Failed to require $pkg.

\$\@ says: $@ and
\$! says: $! and
\$result: $result

"; } my $method_call = "$pkg->${database_action}(\$self)"; $result .= eval "$method_call;"; if ($@) { $result .= "

$me: $method_call failed.

\$\@ says: $@ and
\$! says: $! and
\$result is: $result

"; } my $output .= My::CGIOut->build_page($self, $result); # Process the template return $output; }