require
require filename require num require package
- Asserts a dependency of some kind depending on its argument. (If an argument is not supplied,
$_is used.)If the argument is a string filename, this function includes and executes the Perl code found in the separate file of that name. This is similar to performing an
evalon the contents of the file, except thatrequirechecks to see that the library file has not been included already. The function also knows how to search the include path stored in the@INCarray.If
requires argument is a number num, the version number of the currently executing Perl binary (as known by$]) is compared to num, and if smaller, execution is immediately aborted. Thus, a script that requires Perl version 5.003 can have as its first line:require 5.003;
and earlier versions of Perl will abort.If
requires argument is a package name,requireassumes an automatic pm suffix, making it easy to load standard modules. This is likeuse, except that it happens at runtime, not compile time, and theimportroutine is not called.