=over =item do BLOCK X X Not really a function. Returns the value of the last command in the sequence of commands indicated by BLOCK. When modified by the C or C loop modifier, executes the BLOCK once before testing the loop condition. (On other statements the loop modifiers test the conditional first.) C does I count as a loop, so the loop control statements L|/next LABEL>, L|/last LABEL>, or L|/redo LABEL> cannot be used to leave or restart the block. See L for alternative strategies. =item do EXPR X 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 the current filename for error messages, searches the L|perlvar/@INC> directories, and updates L|perlvar/%INC> if the file is found. See L and L for these variables. It also differs in that code evaluated with C cannot see lexicals in the enclosing scope; C 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. If L|/do EXPR> can read the file but cannot compile it, it returns L|/undef EXPR> and sets an error message in L|perlvar/$@>. If L|/do EXPR> cannot read the file, it returns undef and sets L|perlvar/$!> to the error. Always check L|perlvar/$@> first, as compilation could fail in a way that also sets L|perlvar/$!>. If the file is successfully compiled, L|/do EXPR> returns the value of the last expression evaluated. Inclusion of library modules is better done with the L|/use Module VERSION LIST> and L|/require VERSION> operators, which also do automatic error checking and raise an exception if there's a problem. You might like to use L|/do EXPR> to read in a program configuration file. Manual error checking can be done this way: # read in config files: system first, then user for $file ("/share/prog/defaults.rc", "$ENV{HOME}/.someprogrc") { unless ($return = do $file) { warn "couldn't parse $file: $@" if $@; warn "couldn't do $file: $!" unless defined $return; warn "couldn't run $file" unless $return; } } =back