in reply to Chain

Circular references tend to lead to things like core dump. I would look at rewriting these modules so that they are not co-dependant like that.

Replies are listed 'Best First'.
RE: Re: Chain
by jettero (Monsignor) on Aug 15, 2000 at 01:11 UTC
    I voted you up for that response ... I started re-writing it anyway. But what I was really lookin for was something like this (but a perl solution):
    #ifndef HAPPY #define HAPPY The code that may have already been included elsewhere. #endif
      In that case you would probably want to use eval to run test perl code that would run correctly if your library's function was loaded, otherwise it would bomb. Eval will trap the bomb, and allow you to decide wether or not to lode the library. However, I'd follow Adam's advice :) .

      Caio,
      Gryn

      You can use the c precompiler with perl. (-P)

      Or you could put a similar check in the BEGIN block of you package, along with some wizardry to get out of the package from the BEGIN block... maybe a goto or something.   (I wouldn't die or exit there, and returning would just get you out of the BEGIN block, not the package.)

      Are you aware of AUTOLOAD? It is meant for run-time on-demand loading of functions. I abused it in JAPH at the firing range but what you are supposed to do is check $AUTOLOAD and then autoload some functionality.

      There is a standard module Autoloader which can be used to simplify this process if you have a lot of functions you want loaded dynamically at run-time.