in reply to help with versioning modules

Part of the reason I created MooX::Press and portable::loader was to create classes that were divorced from the Perl namespace, so you can have different versions of the same API which don't stomp on each others' namespaces.

Try this for an example:

git clone git@github.com:tobyink/misc-versioned-library-example-p5.git cd misc-versioned-library-example-p5 curl -fsSL --compressed https://git.io/cpm | perl - install perl -Ilocal example.pl

(Assumes you have Perl 5.10+, git, and curl.)

This is the contents of example.pl:

#!/usr/bin/env perl use strict; use warnings; use feature 'say'; use portable::lib './lib'; use portable::alias 'Foo-1.0' => 'FooOld'; use portable::alias 'Foo-1.1' => 'Foo'; # Foo 1.0 my $bar = FooOld->new_bar( name => 'X', desc => 'Y' ); say $bar->desc; # Foo 1.1 changed 'desc' to 'description' $bar = Foo->new_bar( name => 'X', description => 'Y' ); say $bar->description;

And here's the definition of Foo 1.1:

use strict; use warnings; return { version => '1.1', class => { 'Bar' => { has => { 'name' => { type => 'Str' }, 'description' => { type => 'Str' }, }, }, }, }

You could add a method to the Bar class like this:

'Bar' => { has => { 'name' => { type => 'Str' }, 'description' => { type => 'Str' }, }, can => { 'do_something' => sub { my $self = shift; return 42 }, }, },