# In the main program
push @INC, new Foo(...);
+Note that these hooks are also permitted to set the %INC entry
+corresponding to the files they have loaded. See L<perlvar/%INC>.
+
For a yet-more-powerful import facility, see L</use> and L<perlmod>.
=item reset EXPR
If the file was loaded via a hook (e.g. a subroutine reference, see
L<perlfunc/require> for a description of these hooks), this hook is
-inserted into %INC in place of a filename.
+by default inserted into %INC in place of a filename. Note, however,
+that the hook may have set the %INC entry by itself to provide some more
+specific info.
=item %ENV
use File::Spec;
require "test.pl";
-plan(tests => 39);
+plan(tests => 43);
my @tempfiles = ();
is( $INC{'Quux2.pm'}, $sref, ' key is correct in %INC' );
pop @INC;
+
+push @INC, sub {
+ my ($self, $filename) = @_;
+ if (substr($filename,0,4) eq 'Toto') {
+ $INC{$filename} = 'xyz';
+ return get_temp_fh($filename);
+ }
+ else {
+ return undef;
+ }
+};
+
+ok( eval { require Toto; 1 }, 'require() magic via anonymous code ref' );
+ok( exists $INC{'Toto.pm'}, ' %INC sees it' );
+ok( ! ref $INC{'Toto.pm'}, q/ key isn't a ref in %INC/ );
+is( $INC{'Toto.pm'}, 'xyz', ' key is correct in %INC' );
+
+pop @INC;