=over =item require VERSION =item require EXPR =item require Demands some semantics specified by EXPR, or by C<$_> if EXPR is not supplied. If a VERSION is specified as a literal of the form v5.6.1, demands that the current version of Perl (C<$^V> or $PERL_VERSION) be at least as recent as that version, at run time. (For compatibility with older versions of Perl, a numeric argument will also be interpreted as VERSION.) Compare with L, which can do a similar check at compile time. require v5.6.1; # run time version check require 5.6.1; # ditto require 5.005_03; # float version allowed for compatibility Otherwise, demands that a library file be included if it hasn't already been included. The file is included via the do-FILE mechanism, which is essentially just a variety of C. Has semantics similar to the following subroutine: sub require { my($filename) = @_; return 1 if $INC{$filename}; my($realfilename,$result); ITER: { foreach $prefix (@INC) { $realfilename = "$prefix/$filename"; if (-f $realfilename) { $INC{$filename} = $realfilename; $result = do $realfilename; last ITER; } } die "Can't find $filename in \@INC"; } delete $INC{$filename} if $@ || !$result; die $@ if $@; die "$filename did not return true value" unless $result; return $result; } Note that the file will not be included twice under the same specified name. The file must return true as the last statement to indicate successful execution of any initialization code, so it's customary to end such a file with C<1;> unless you're sure it'll return true otherwise. But it's better just to put the C<1;>, in case you add more statements. If EXPR is a bareword, the require assumes a "F<.pm>" extension and replaces "F<::>" with "F" in the filename for you, to make it easy to load standard modules. This form of loading of modules does not risk altering your namespace. In other words, if you try this: require Foo::Bar; # a splendid bareword The require function will actually look for the "F" file in the directories specified in the C<@INC> array. But if you try this: $class = 'Foo::Bar'; require $class; # $class is not a bareword #or require "Foo::Bar"; # not a bareword because of the "" The require function will look for the "F" file in the @INC array and will complain about not finding "F" there. In this case you can do: eval "require $class"; For a yet-more-powerful import facility, see L and L. =back