in reply to Managing Architecture-Dependant Perl Modules in an Object-Oriented Hierarchy

I wouldn't mingle architecture dependent stuff in one module. That's a formula for hard-to-read, harder-to-maintain C-style #ifdef code.

That said, the Perl compiler will optimize away code paths that it can't possibly reach, like the following:

while (0) { for (1 .. 1000000000) {} }

Provided you have some sort of flag to mark sections of code as irrelevant to the current architecture, I think you'll be okay. (The disclaimer is that I haven't tried this in a while.)

If I were doing this, I would write wrapper classes, as you suggest. This'll provide one consistent interface for your main module to use. Your wrappers can take care of massaging the divergencies.

I'd write a tiny setup script that has the arch-dependent code in it, to check $^O and initialize the appropriate wrapper (which initializes the arch-dependent module). Then pass that wrapper instance into the constructor of the main module.

That leaves your main module relatively clean, and puts the nasty stuff away elsewhere where you don't have to work around it when you're more concerned about the business rules in your main module.

  • Comment on Re: Managing Architecture-Dependant Perl Modules in an Object-Oriented Hierarchy
  • Download Code

Replies are listed 'Best First'.
Why Win32::Internet (Re: Managing Architecture-Dependant Perl Modules in an Object-Oriented Hierarchy)
by tye (Sage) on Sep 21, 2000 at 20:20 UTC

    I'd much rather have the OS-dependent stuff in a module than repeated in every script that needs to portably do what is provided by several OS-specific modules! Modules are the best place for the "ugly" code that is sometimes needed.

    But, Net::FTP is already portable so there is no need to ever use Win32::Internet for doing FTP from Perl. Info about advantages of Win32::Internet over Net::FTP are welcome. I'm curious if there are any.

            - tye (but my friends call me "Tye")
      I found an advantage to Win32::Internet over standard portable alternatives.

      I had problems proxying https connections, but on Windows if I just used Win32::Internet it worked like a charm. Since I just needed a quick answer that ran on someone's desktop, I left it at that rather than worrying about SSLeay, etc (which really was not cooperating).

      Never tried to track down the proxying problem since I never had to, but if someone else has I wouldn't mind knowing what the issue was...