DBIx::VersionedSubs::Hash - store subroutines in a simple hash


  package My::App;
  use strict;
  use base 'DBIx::VersionedSubs::Hash';

  __PACKAGE__->{code} = {
      say_hello => sub {print "Hello World"},

  package main;
  use strict;

  my $app = My::App->new({code => {},dsn => $dsn );
  while (my $request = Some::Server->get_request) {
      $app->update_code(); # update code from the DB


This module overrides some methods in DBIx::VersionedSubs and replaces the normal namespace based code storage with simple storage in a hash. This is useful if you want multiple code versions in a mod_perl environment for example.

Package->new({ %ARGS })

Creates a new object and initializes it from the class default values as inherited from DBIx::VersionedSubs.

If you pass in a hashref to the code key, all subroutines will be stored in it. You can also use this feature to pass in a package hash (like %My::App:: ), then this module will be almost identical in usage to DBIx::VersionedSubs itself. The difference between the two is that subroutine names with characters outside of \w will not create subroutines in other namespaces with this module.

$app->dispatch( FUNCTION, ARGS )

This is a shorthand method for

    return $self->{code}->{$function}->(@ARGS);

except with error checking


Max Maischein, <>


This module is licensed under the same terms as Perl itself.