The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

loading - Pragma to exempt a module from loading

VERSION

Version 1.01

SYNOPSIS

In some file (probably a script)

    BEGIN {
        package Some::Module;
        no loading; # exempt the current package (Some::Module) from loading
        use Exporter qw(import);
        our @EXPORT = qw(lala);

        sub lala { print "lala\n" }
    }

    use Some::Module; # would die without "no loading" above

    lala; # prints "lala", imported from Some::Module

Alternatively you can specify the package(s) to exempt from loading in the no statement

    BEGIN {
        package Some::Module;
        use Exporter qw(import);
        our @EXPORT = qw(lala);

        sub lala { print "lala\n" }
    }
    no loading qw(Some::Module); # exempt Some::Module from loading

    use Some::Module;
    lala;

Description

no loading dispenses the current package from being loaded from a .pm file when used later in the same file.

no loading qw(Some::Module Other::Module) dispenses the named moduled from being loaded.

If a module has already been loaded from somewhere no loading is a no-op, so it does no harm. use loading ...; has no effect, it doesn't countermand no loading ...;.

In effect, no loading saves you the

    BEGIN { Some::Module->import(<args>) }

you'd have to write in place of a use-statement in the same file where Some::Module is defined. That's a convenience, but it makes the file more readable. If the purpose of the file is to demonstrate various use-statements, the difference may be significant.

AUTHOR

Anno Siegel, <anno5 at mac.com>

BUGS

Please report any bugs or feature requests to bug-loading at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=loading. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc loading

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2014 Anno Siegel.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.