use POSIX qw(setsid);
use( ) internally performs two operations:
The first operation loads and compiles the module. The second calls
the module's import( ) method and
specifies to import the symbol setsid into the
caller's namespace. The BEGIN
block makes sure that the code is executed as soon as possible,
before the rest of the code is even parsed. POSIX,
like many other modules, specifies a default export list. This is an
especially extensive list, so when you call:
about 500 KB worth of symbols gets imported.
Usually, we don't need POSIX or
its symbols in the startup file; all we want is to preload it.
Therefore, we use an empty list as an argument for use(
use POSIX ( );
so the POSIX::import( ) method
won't be even called.
When we want to use the POSIX module in the code,
we use( ) it again, but this time no loading
overhead occurs because the module has been loaded already. If we
want to import something from the module, we supply the list of
symbols to load:
use POSIX qw(:flock_h);
This example loads constants used with the flock(
Technically, you aren't required to supply the
use( )statement in your handler code if the
module has already been loaded during server startup or elsewhere.
When writing your code, however, don't assume that
the module code has been preloaded. Someday in the future, you or
someone else will revisit this code and will not understand how it is
possible to use a module's methods without first
loading the module itself.
Please refer to the Exporter and
perlmod manpages, and to the section on
use( ) in the perlfunc
manpage for more information about import( ).
Remember that you can always use require( ) to
preload the files at server startup if you don't add
( ), because:
is the same as:
use Data::Dumper ( );
except that it's not executed at compile-time.