NAME

circular::require - detect circularity in use/require statements

VERSION

version 0.05

SYNOPSIS

package Foo;
use Bar;

package Bar;
use Foo;

package main;
no circular::require;
use Foo; # warns

or

perl -M-circular::require foo.pl

DESCRIPTION

Perl by default just ignores cycles in require statements - if Foo.pm does use Bar and Bar.pm does use Foo, doing use Foo elsewhere will start loading Foo.pm, then hit the use statement, start loading Bar.pm, hit the use statement, notice that Foo.pm has already started loading and ignore it, and continue loading Bar.pm. But Foo.pm hasn't finished loading yet, so if Bar.pm uses anything from Foo.pm (which it likely does, if it's loading it), those won't be accessible while the body of Bar.pm is being executed. This can lead to some very confusing errors, especially if introspection is happening at load time (make_immutable in Moose classes, for example). This module generates a warning whenever a module is skipped due to being loaded, if that module has not finished executing.

In some situations, other modules might be handling the module loading for you - use base and Class::Load::load_class, for instance. To avoid these modules showing up as the source of cycles, you can use the -hide parameter when using this module. For example:

no circular::require -hide => [qw(base parent Class::Load)];

or

perl -M'-circular::require -hide => [qw(base parent Class::Load)];' foo.pl

CAVEATS

This module works by overriding CORE::GLOBAL::require, and so other modules which do this may cause issues if they aren't written properly. This also means that the effect is global, but this is typically the most useful usage.

BUGS

No known bugs.

Please report any bugs through RT: email bug-circular-require at rt.cpan.org, or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=circular-require.

SUPPORT

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

perldoc circular::require

You can also look for information at:

AUTHOR

Jesse Luehrs <doy at tozt dot net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Jesse Luehrs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.