Re: contention for require()'d code library

[prev] [thread] [next] [Date index for 2005/02/10]

From: Matthew Berk
Subject: Re: contention for require()'d code library
Date: 17:01 on 10 Feb 2005
I have come up with a bit of a hackish, near term solution. Wanted to 
share it with the group.

  - check to see if a subroutine in the library is defined()
  - if not, delete() the library name from %INC
  - require() the library

This corrects the behavior we were seeing quite well, without much 
overhead for recompilation. Again, the case was:

  - registry script foo.pl
  - registry script bar.pl
  - library lib.pl
  - both scripts require() the library

Best,

Matthew


On Feb 8, 2005, at 11:52 AM, Joe Schaefer wrote:

> Matthew Berk <matthew@xxxxxxx.xxx> writes:
>
>> Apologies in advance for the conceptual nature of this inquiry.
>>
>> I have two chunks of code that are being run as separate scripts under
>> Registry. Both are using require() (I know, I know) to pull in a
>> library of subroutines.
>
> If you're abusing require() as a means of adding external
> subroutines directly into your script, then that's not
> going to work with Registry.  One thing that works, I think,
> would be to use a package declaration at the start of the library,
> and change the script to call those subroutines by their
> package-qualified names:
>
>                 old lib: sub foo {} ...
>                 new lib: package Foo; sub foo{} ...
>              old script: require $mylib; foo(4); ...
>              new script: require $mylib; Foo::foo(4); ...
>
> This may not be the best solution, but I'm sure this issue is well
> documented somewhere on the perl.apache.org site.
>
> -- 
> Joe Schaefer
>

(message missing)

contention for require()'d code library
Matthew Berk 16:28 on 08 Feb 2005

Re: contention for require()'d code library
Perrin Harkins 16:34 on 08 Feb 2005

Re: contention for require()'d code library
Joe Schaefer 16:52 on 08 Feb 2005

Re: contention for require()'d code library
Matthew Berk 17:01 on 10 Feb 2005

Re: contention for require()'d code library
Perrin Harkins 17:09 on 10 Feb 2005

Generated at 11:21 on 20 Feb 2005 by mariachi v0.52