perlquestion
pileofrogs
<p>Greetings Monks.</p>
<p>I'm writing a test to make sure a new version of a perl module is compatible with an old version. The most obvious way to do that is to run the various functions from both versions and compare the result.</p>
<p>Obviously I can't just 'use' or 'require' the two modules, as they have the same package name and the same subroutine names and so on. The solution, it seems to me, would be to load the first version, then rename it's package somehow.</p>
<p>Something like this:</p>
<code>
use Test::More;
require 'old_lib/Foo/Bar.pm';
change_package_name('Foo::Bar','Old::Foo::Bar');
require 'lib/Foo/Bar.pm';
ok( Foo::Bar::baz('wibble') eq Old::Foo::Bar::baz('wibble'),'baz is compatible');
...etc...
</code>
<p>Thanks!<br>--Pileofrogs</p>