How about the Factory Pattern?
Factory.pm
Module_1.pmpackage Factory; use base qw( Class::Factory ); use Module_1; use Module_2; __PACKAGE__->add_factory_type('1.0' => 'Module_1'); __PACKAGE__->add_factory_type('2.0' => 'Module_2'); 1;
Module_2.pmpackage Module_1; sub new { bless {}, shift } sub init { shift } sub version { '1.0' } 1;
And the driver:package Module_2; sub new { bless {}, shift } sub init { shift } sub version { '2.0' } 1;
#!/usr/bin/perl -l use Factory; print $_->version for Factory->new('1.0'), Factory->new('2.0'), ;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: Howto implement versions of object instances
by jeffa
in thread Howto implement versions of object instances
by pajout
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |