Module::Notify - trigger a callback when a module is loaded
use Module::Notify; Module::Notify->new(Foo => sub { print "2\n" }); # Count to three... print "1\n"; require Foo; print "3\n";
Module::Notify runs callback code when it detects that a particular module has been loaded.
new($module_name, $callback)
Runs the callback when the module is loaded.
Unlike most OO modules, you can freely use this in void context, and it will work fine. However, if you keep the returned reference, you can call methods on it:
my $handle = Module::Notify->new($module, $callback);
If the module is already loaded, runs the callback immediately, and returns undef instead of an object.
cancel
Cancels the callback.
Module::Notify works through an @INC hook. It ought to be the first item in @INC and does its best to insert itself as $INC[0] at every opportunity it gets.
@INC
$INC[0]
If any other path or hook does end up before Module::Notify's @INC hook, then any modules loaded via that path or hook will escape Module::Notify's notice.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Module-Notify.
Module::Runtime.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Module::Notify, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Notify
CPAN shell
perl -MCPAN -e shell install Module::Notify
For more information on module installation, please visit the detailed CPAN module installation guide.