perlfunc: document return behavior of require and module_true feature

This commit is contained in:
Grinnz 2025-12-10 17:05:18 -05:00 committed by Paul Evans
parent 8fd53b46c5
commit 966e97bd7e
2 changed files with 7 additions and 0 deletions

View File

@ -232,6 +232,7 @@ Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Dagfinn Ilmari Mannsåker (via RT)
Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> ilmari@vesla.ilmari.org <ilmari@vesla.ilmari.org>
Damian Conway <damian@conway.org> Damian Conway <damian@cs.monash.edu.au>
Dan Book <grinnz@grinnz.com> Dan <grinnz@grinnz.com>
Dan Book <grinnz@grinnz.com> Grinnz <grinnz@grinnz.com>
Dan Dascalescu <bigbang7@gmail.com> Dan Dascalescu <ddascalescu+github@gmail.com>
Dan Faigin <unknown> Dan Faigin, Doug Landauer <unknown@longtimeago>
Dan Jacobson <jidanni@jidanni.org> Dan Jacobson <jidanni@hoffa.dreamhost.com>

View File

@ -7111,6 +7111,7 @@ would have semantics similar to the following:
croak $@ ? "$@Compilation failed in require"
: "Can't locate $filename: $!\n";
}
return 1 if $feature_module_true_enabled_in_file;
if (!$result) {
delete $INC{$filename};
croak "$filename did not return true value";
@ -7136,6 +7137,11 @@ affects the compilation unit within which the feature is used, and using
it before requiring a module will not change the behavior of existing
modules that do not themselves also use it.
In this usage, the (truthy) result of the required file will be returned,
but this should not be relied upon as it will not be returned in subsequent
C<require> calls on the same file or with the 'module_true' feature enabled.
To run a file and retrieve its return value, use L<C<do>|/do EXPR>.
If EXPR is a bareword, C<require> assumes a F<.pm>
extension and replaces C<::> with C</> in the filename for you,
to make it easy to load standard modules. This form of loading of