...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.Foo.pm did not return a true value at -e line 1.
In case there's some other error I'm missing, here's the current version of the sub I'm inserting into @INC:
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.)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; }; }
In reply to Re^2: Telling require "I've handled it"
by dsheroh
in thread Telling require "I've handled it"
by dsheroh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |