Not really a function. Returns the value of the last command in the
sequence of commands indicated by BLOCK. When modified by the
loop modifier, executes the BLOCK once before testing the loop
condition. (On other statements the loop modifiers test the conditional
This form of subroutine call is deprecated. SUBROUTINE can be a bareword or scalar variable.
Uses the value of EXPR as a filename and executes the contents of the file as a Perl script.
- do 'stat.pl';
is largely like
- eval `cat stat.pl`;
except that it's more concise, runs no external processes, keeps track of
filename for error messages, searches the
directories, and updates
if the file is found. See @INC in perlvar and %INC in perlvar for
these variables. It also differs in that code evaluated with
cannot see lexicals in the enclosing scope;
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.
do can read the file but cannot compile it, it returns
undef and sets
an error message in
do cannot read the file, it returns undef
to the error. Always check
first, as compilation
could fail in a way that also sets
. If the file is successfully
do returns the value of the last expression evaluated.
You might like to use
do to read in a program configuration
file. Manual error checking can be done this way: