Fellow monks,

I have an interesting dillema. Due to forces outside of my control, I have to work with existing code which has something like:

use myPackage; myPackage::foo(); myPackage::bar();

The problem is that in my environment, I cannot have the obsolete myPackage module because it has been replaced with myNewPackage module. The nice thing is that this myNewPackage has almost a one to one mapping of function names (and their functionality). So, I was hoping to write my own dummy myPackage which would actually do something like:
package myPackage; use strict; use myNewPackage; # magically convert myNewPackage::* to myPackage()::* # except for one function where myNewPackage::bar() needs to actually +provide myPackage::old_bas()
it seems like something like this should be possible, but I cannot think of an easy way to do it short of actually going through every function and creating an explicit mapping like (pseudocode):
sub myPackage::a { return myNewPackage::a(@_); } sub myPackage::b { return myNewPackage::b(@_); } sub myPackage::old_bas { return myNewPackage::bar(@_); }
Does anyone have any good ideas for how to deal with this?

thanks as always!


In reply to creating a wrapper module for bacward compatibility by gri6507

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.