in reply to Can perl modules be compiled?

Well, many thanks, Joost! I have made the necessary modifications to my modules to use AutoLoader and presto! Now, my script loads in about 2 seconds, instead of 10!

Amazing!!!

However, when I compile my module, I get a bunch of warnings (I believe):
AutoSplitting blib/lib/RTC/Telnet.pm (blib/lib/auto/RTC/Telnet)
blib/lib/RTC/Telnet.pm: some names are not unique when truncated to 8 characters:
 directory blib/lib/auto/RTC/Telnet:
  getHostnameCisco.al, getHostnameTelco.al, getHostnameEricsson.al truncate to getHostn
  getInterfaces.al, getInterfacesCisco.al, getInterfacesTelco.al, getInterfacesEricsson.al truncate to getInter
  loginToCisco.al, loginToCiscoCPE.al, loginToCiscoCPEthruHQ.al truncate to loginToC
  logoutOfCisco.al, logoutOfTelco.al, logoutOfEricsson.al, logoutOfCiscoCPE.al, logoutOfCiscoCPEthruHQ.al truncate to logoutOf
  runCommands.al, runCommandsCisco.al, runCommandsTelco.al, runCommandsEricsson.al, runCommandsCiscoCPE.al truncate to runComma


My script seems to be running just fine, anyway... Is there a problem with these messages?

Replies are listed 'Best First'.
Re^2: Can perl modules be compiled?
by Corion (Patriarch) on Feb 26, 2007 at 12:57 UTC

    This is "only" a problem when you're running on platforms that have an 8-char limit to the filenames, like DOS has. Otherwise you should be fine.

Re^2: Can perl modules be compiled?
by demerphq (Chancellor) on Feb 26, 2007 at 17:00 UTC

    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

      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 :)