Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

geoff (2013)

  reversethis-{gro ... om} {ta} {ffoeg}

see [] for personal information, links to presentations, GPG key, and so on.

Journal of geoff (2013)

Wednesday January 16, 2002
11:31 AM

CV in @INC

[ #2185 ]
did you know that you can store a coderef in @INC?

so, I went to dinner with my friend jeff so that we can have our semi-regular gripe session about the pains of authorship (he's working on a sysadmin book). anyway, we start talking about extproc_perl and he mentions that he is trying to solve some performance issues. apparently, the holy grail of extproc_perl is to be able to create indexes in Oracle using perl regular expressions (wow). anyway, apparently, through some coverstations with Tim Bunce, it was suggested that perhaps using the coderef-in-@INC hack might be able to help.

now, I'm not sure what the two of them were talking about, but jeff sent me this link and I poked around the threads some. now my mind is racing. this is sooooo cool.

seems like, among other things, you could have all pure-perl modules on some website and *poof* no more distribution problems. damn, that's cool. barrie slaymaker mentioned on #axkit the possibility of a plug-in that installed a library if it couldn't be require()d. ok, so it's a bit crazy, but I'm a firm believer in the "if you build it, they will come" approach to programming.

hmph. wonder if I'll find the time to play with this...
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Abigail demonstrated this [] on Perlmonks a while back. You can find The::Net in Abigail's CPAN directory, too. It does exactly what you suggest.
    • excellent!

      thanks for the link. I just can't keep up these days.
    • Bah. I just found a bug of sorts. In pp_ctl.c, there is this:

          if (PERL_FILE_IS_ABSOLUTE(name)
          || (*name == '.' && (name[1] == '/' ||
                       (name[1] == '.' && name[2] == '/'))))
          tryname = name;
          tryrsfp = doopen_pmc(name,PERL_SCRIPT_MODE);
          else {

      Now, the code to call the coderef only happens in the else. So if the file is determin

      • There are a couple of possibilities. Paths with leading protocol designations obviously don't mean the same thing with regard to "absolute" or "relative" paths. There could be another conditional to see if it looks like a local filesystem filepath -- if not, it punts to a coderef.

        Another option is to say that URIs obviously aren't absolute in any sense that matters, though that conflates two slightly-different uses of the word. (The Mac behavior you describe seems wrong to me, but I've been known to be

        • The Mac behavior's not wrong; if you have a volume "http" you could have a file "//foo/", and it would be "http://foo/".

          But I think it would be Wrong to try to special-case URIs; having coderefs in @INC shouldn't be purpose-specific. What if I want to remove all the actual paths in @INC and handle everything via some custom handler? e.g., maybe if it is a Slash module I'll try to get it from my /usr/local/src/slash/ directory, otherwise look in /usr/local/lib/.

          And if that is the case, if t
  • I use the coderef-in-@INC trick, along with various nasty things involving local $INC{$package}, closures and evaling stuff with the expectation that it'll fail to get at package scoped lexicals in the refactoring engine I've been working on.

    It's one of those hacks that seems at once utterly fantastic whilst at the same time being totally bloody evil.