in reply to Re: Can perl modules be compiled?
in thread Can perl modules be compiled?

I think you should use or complement your current approach with a different strategy. Your sub names strongly suggest that your code should be split into multiple modules, probably OO ones. So you would have Mymod.pm as a base class with MyMod::Cisco, MyMod::Cisco::CPEthruHQ, MyMod::Cisco::CPE, MyMod::Telco, MyMod::Ericson as subclasses. Then you would simply have a base set of routines: getHostname(), getInterfaces(), login(), logout(), runCommands(), which would be overriden as necessary in the subclasses. This would reduce the initial load time since you would only load the baseclass and then let it load on the fly the appropriate subclass. And it would still be possible to use Autoloader, but with no possibilitiy of file name clashes, and most likely be much easier to work with.

You have to think that whenever you have subs named like you do that you probably are doing the subroutine equivelent of numbered variables like $x1,$x2,$x3, which is almost always a product of bad design. The same thing applied to subroutines, except that the solution is to use OO and not a hash or an array. (Although you could use a hash based dispatch table, but why bother, using subclasses is easier and is specifically designed for this type of scenario.)

---
$world=~s/war/peace/g

Replies are listed 'Best First'.
Re^3: Can perl modules be compiled?
by mad_ady (Acolyte) on Feb 27, 2007 at 06:43 UTC
    Yes, you are right about splitting the module into smaller individual parts; it's just that when I started writing it, I didn't think it would grow to this size ... and now it's a bit of a challenge to untangle it. :) Actually this would have been my strategy if AutoLoader wouldn't have worked.
    As for the OO aproach... well, I haven't studied yet how to write OO in perl, so I wouldn't venture here. I agree that I could have written the whole thing to be more efficient, but I don't really have the time to optimize it - it has to run first :)