my $instance1 = MyModule::new('1.0'); print $instance1->version(); #prints '1.0'; my $instance2 = MyModule::new('2.0'); print $instance2->version(); #prints '2.0'; #### package MyModule; our $VERSION = '2.0'; our $vers = {'1.0'=>{__PACKAGE__.'::version'=>\&version_1_0}, '2.0'=>{__PACKAGE__.'::version'=>\&version_2_0}}; #### sub new { my $class = __PACKAGE__; my $version = shift || $VERSION; return bless({methods=>$$vers{$version}},$class); } #### sub AUTOLOAD { my $self = $_[0]; return &{$$self{methods}{$AUTOLOAD}}(@_); }