That's a step in the right direction, at least, but return sub { $_ = "1;"; 0; }; (with or without the explicit return) gets me
Foo.pm did not return a true value at -e line 1.
...which is very odd, seeing as that's the exact same thing you're returning from your example code. Requiring any combination of Foo and Local::Foo without my sub in place works fine, so I'm fairly confident that the problem is with the sub, not the modules being loaded.

In case there's some other error I'm missing, here's the current version of the sub I'm inserting into @INC:

BEGIN { unshift @INC, \&require_local } sub require_local { # Exit immediately if we're not processing overrides return if $core_only; my (undef, $filename) = @_; # Keep track of what files we've already seen to avoid infinite lo +ops return if exists $already_seen{$filename}; $already_seen{$filename}++; # We only want to check overrides in $base_namespace return unless $filename =~ /^$base_namespace/; # OK, that all passed, so we can load up the actual files # Get the original version first, then overlay the local version say STDERR "requiring $filename"; require $filename; my $local_file = $filename; if ($base_namespace) { $local_file =~ s[^$base_namespace][${base_namespace}/Local]; } else { # Empty base namespace is probably a bad idea, but it should b +e # handled anyhow $local_file = 'Local/' . $local_file; } $already_seen{$local_file}++; say STDERR "requiring $local_file"; # Failure to load local version is not fatal, since it may not exi +st no warnings 'redefine'; eval { require $local_file }; say STDERR "Done."; return sub { $_ = "1;"; 0; }; }
All three messages are appear on STDOUT, along with the subroutine redefined warning for the sub I've duplicated in Local/Foo.pm, so the sub is definitely running all the way through. It just seems to be returning a false value. (I also tried return sub { $_ = "1;"; 1; }; and, as I expected, it went into an infinite loop waiting for the returned sub to declare EOF.)

In reply to Re^2: Telling require "I've handled it" by dsheroh
in thread Telling require "I've handled it" by dsheroh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.