Clear questions and runnable code
get the best and fastest answer
How to morph a plain module to OOby Rudif (Hermit)
|on Sep 07, 2002 at 18:04 UTC||Need Help??|
Rudif has asked for the
wisdom of the Perl Monks concerning the following question:
I have a plain old module that I wrote before I was conversant with Perl OO.
It provides a several subroutines, which I call from many scripts, built up over several years.
At present, I want to morph my module to OO (so that each instance can have a state which is accessible to all subs). However, I want to morph the module in a such way that my old scripts continue to work, and that my new scripts can use the OO syntax and other goodies. I found one way to do this, shown below on a very simple example.
Learned monks, I would like to see your comments on other, perhaps better ways to achieve my goal.
MyModule before the change
A test script, before the change
MyModule after the change
A test script, after the change