in reply to Re: Chain
in thread Chain

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

Replies are listed 'Best First'.
Use Eval
by gryng (Hermit) on Aug 15, 2000 at 01:49 UTC
    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

RE: RE: Re: Chain
by Adam (Vicar) on Aug 15, 2000 at 01:35 UTC
    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.)

RE (tilly) 3: Chain
by tilly (Archbishop) on Aug 15, 2000 at 10:44 UTC
    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.