Help for this page

Select Code to Download


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