Stories
Slash Boxes
Comments
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Abigail demonstrated this [perlmonks.org] on Perlmonks a while back. You can find The::Net in Abigail's CPAN directory, too. It does exactly what you suggest.
    • 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 determined to be absolute, but it is *not* able to be opened, then the coderef is never called. Try requiring something like "/foo" or "./foo", your coderef won't get called.

      I ran into this because the Mac OS equivalent treats "http://foo/bar.pm" as an absolute path, so PERL_FILE_IS_ABSOLUTE(name) returns true, so the coderef is never called.

      Bah, I say! Any thoughts?

      • 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/bar.pm", and it would be "http://foo/bar.pm".

          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