in reply to 'use' falls out of scope at runtime

Is this a CGI script or a mod_perl Registry script (or ...)? Could you please clarify what you mean by "falling out of scope"?
  • Comment on Re: 'use' falls out of scope at runtime

Replies are listed 'Best First'.
Re^2: 'use' falls out of scope at runtime
by arpx (Acolyte) on Apr 23, 2009 at 14:06 UTC
    its all MP scripts, .pm modules with a set of functions each im trying to import from the main program which is a mod_perl script running backend in apache

    the first run after restart loads the extra modules together with the initial enviroment. but the 2nd run doesnt want to find them without reloading them, the initial enviroment is stable though

      I can see three possibilities.

      • You don't actually have a module.

        As I define a module, it must have its own namespace and placed there using a package statement.

      • The runs are in different Apache processes.

        Apache has many children to handle requests. Loading a module in one won't load it in the others (unless you load it in the mod_perl startup script).

      • The module is loaded, but the symbols haven't been imported into the current namespace.

        use Some::Such; has two effects: require and import. A module only needs to be required once. (Subsequent calls to require are no-ops.) But you need to call import from each namespace into which you want to import.

      Apache also restarts its children from time to time.

        Tx for the answer.

        1) the module is there, it loaded and ran my test on the first page hit, the second page hit the enviroment forgot he had taken it in unless i go though the use statment again

        2) just one proc. i see if the main env is reproduced and so is not the case here

        3) i run the 'use' statment in the namespace i call, just use one namespace. since it imports early in the application, and oo objects are started in that namespace later in the first run, successfully, it seems strange why it would drop in the next run