package Storage::Factory; { use Storage::SQLite; use Storage::MySQL; sub new { my $class = shift; my $opt = {@_}; return Storage::SQLite->new(file => $opt->{dsn}) if $opt->{type} eq 'sqlite'; return Storage::MySQL->new(dsn => $opt->{dsn}) if $opt->{type} eq 'mysql'; } } 1; use Storage::Factory; my $storage = Storage::Factory->new(%{ $self->plugin('Config')->{db} })