In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/a03e9f8a07a84c3d506eb4b6cce401a71f7d41f9?hp=feca1ab570be3a64bda3f74fe004fab5a85e959a>
- Log ----------------------------------------------------------------- commit a03e9f8a07a84c3d506eb4b6cce401a71f7d41f9 Author: Dominic Hargreaves <[email protected]> Date: Tue Feb 21 20:30:38 2017 +0000 Documentation fixes for '.' possibly no longer being in @INC ----------------------------------------------------------------------- Summary of changes: pod/perlfunc.pod | 28 +++++++++++++++++++--------- pod/perlvar.pod | 7 ++++--- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 10651b4f4f..88d30a55fd 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -1807,20 +1807,30 @@ X<do> Uses the value of EXPR as a filename and executes the contents of the file as a Perl script. - do 'stat.pl'; + do './stat.pl'; is largely like eval `cat stat.pl`; -except that it's more concise, runs no external processes, keeps track of -the current filename for error messages, searches the -L<C<@INC>|perlvar/@INC> directories, and updates L<C<%INC>|perlvar/%INC> -if the file is found. See L<perlvar/@INC> and L<perlvar/%INC> for these -variables. It also differs in that code evaluated with C<do FILE> -cannot see lexicals in the enclosing scope; C<eval STRING> does. It's -the same, however, in that it does reparse the file every time you call -it, so you probably don't want to do this inside a loop. +except that it's more concise, runs no external processes, and keeps +track of the current filename for error messages. It also differs in that +code evaluated with C<do FILE> cannot see lexicals in the enclosing +scope; C<eval STRING> does. It's the same, however, in that it does +reparse the file every time you call it, so you probably don't want +to do this inside a loop. + +Using C<do> with no path, like + + do 'stat.pl'; + +will search the L<C<@INC>|perlvar/@INC> directories, and update +L<C<%INC>|perlvar/%INC> if the file is found. See L<perlvar/@INC> +and L<perlvar/%INC> for these variables. In particular, note that +whilst historically L<C<@INC>|perlvar/@INC> contained '.' (the +current directory) making these two cases equivalent, that is no +longer necessarily the case, as there is now a compile-time option +to disable this behaviour. If L<C<do>|/do EXPR> can read the file but cannot compile it, it returns L<C<undef>|/undef EXPR> and sets an error message in diff --git a/pod/perlvar.pod b/pod/perlvar.pod index b8c68b3455..2f776489be 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -503,9 +503,10 @@ initially consists of the arguments to any B<-I> command-line switches, followed by the default Perl library, probably F</usr/local/lib/perl>, followed by ".", to represent the current directory. ("." will not be appended if taint checks are enabled, -either by C<-T> or by C<-t>.) If you need to modify this at runtime, -you should use the C<use lib> pragma to get the machine-dependent -library properly loaded also: +either by C<-T> or by C<-t>, or if configured not to do so by the +C<-Ddefault_inc_excludes_dot> compile time option.) If you need to +modify this at runtime, you should use the C<use lib> pragma to get +the machine-dependent library properly loaded also: use lib '/mypath/libdir/'; use SomeMod; -- Perl5 Master Repository
