autouse − postpone load of modules until a function is used


   use autouse 'Carp' => qw(carp croak);
  carp "this carp was predeclared and autoused ";


If the module "Module" is already loaded, then the declaration

   use autouse 'Module' => qw(func1 func2($;$));

is equivalent to

   use Module qw(func1 func2);

if "Module" defines func2() with prototype "($;$)", and func1() has no prototypes. (At least if "Module" uses "Exporter"’s "import", otherwise it is a fatal error.)

If the module "Module" is not loaded yet, then the above declaration declares functions func1() and func2() in the current package. When these functions are called, they load the package "Module" if needed, and substitute themselves with the correct definitions.


Using "autouse" will move important steps of your program’s execution from compile time to runtime. This can

Break the execution of your program if the module you "autouse"d has some initialization which it expects to be done early.

hide bugs in your code since important checks (like correctness of prototypes) is moved from compile time to runtime. In particular, if the prototype you specified on "autouse" line is wrong, you will not find it out until the corresponding function is executed. This will be very unfortunate for functions which are not always called (note that for such functions "autouse"ing gives biggest win, for a workaround see below).

To alleviate the second problem (partially) it is advised to write your scripts like this:

  use Module;
    use autouse Module => qw(carp($) croak(&$));
  carp "this carp was predeclared and autoused ";

The first line ensures that the errors in your argument specification are found early. When you ship your application you should comment out the first line, since it makes the second one useless.


Ilya Zakharevich (ilya@math.ohio−



More Linux Commands

perlnetware(1) - Perl for NetWare - Linux manual page.......
This file gives instructions for building Perl 5.7 and above, and also Perl modules for NetWare. Before you start, you may want to read the README file found in

Tk_NameToWindow(3) - convert between names and window tokens
Each window managed by Tk has two names, a short name that identifies a window among children of the same parent, and a path name that identifies the window uni

XkbKeyNumActions(3) - Computes the number of actions associa
XkbKeyNumActions.3 - A key action defines the effect key presses and releases have on the internal state of the server. For example, the expected key action ass

tkill(2) - send a signal to a thread - Linux manual page....
tgkill() sends the signal sig to the thread with the thread ID tid in the thread group tgid. (By contrast, kill(2) can be used to send a signal only to a proces

kdesu-4(1) Runs a program with elevated privileges..........
KDE su is a graphical front end for the UNIX(R)su command for the K Desktop Environment. It allows you to run a program as different user by supplying the passw

Tk_PhotoGetImage(3) - manipulate the image data stored in a
Tk_FindPhoto returns an opaque handle that is used to identify a particular photo image to the other procedures. The parameter is the name of the image, that is

mvget_wstr(3ncurses) - get an array of wide characters from
The effect of get_wstr is as though a series of calls to get_wch were made, until a newline, other end-of-line, or end-of-file condition is processed. An end-of

read_all_mibs(3) - netsnmp_mib_api functions (Man Page).....
The functions dealing with MIB modules fall into four groups - those dealing with initialisation and shutdown, with reading in and parsing MIB files, with searc

zshoptions(1) - zsh options (Commands - Linux man page).....
Options are primarily referred to by name. These names are case insensitive and underscores are ignored. For example, allexport is equivalent to ...............

SDL_FreeSurface(3) - Frees (deletes) a SDL_Surface (ManPage)
Frees the resources used by a previously created SDL_Surface. If the surface was created using SDL_CreateRGBSurfaceFrom then the pixel data is not freed. SEE AL

cbc_crypt(3) - fast DES encryption - Linux manual page......
ecb_crypt() and cbc_crypt() implement the NBS DES (Data Encryption Standard). These routines are faster and more general purpose than crypt(3). They also are ab

gnutls_pkcs7_get_crt_count(3) - API function (Man Page).....
This function will return the number of certifcates in the PKCS7 or RFC2630 certificate set. RETURNS On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a n

We can't live, work or learn in freedom unless the software we use is free.