Hook::AfterRuntime - Run code at the end of the compiling scope's runtime.
Useful for creating modules that need a behavior to be added when a module that uses them completes it's runtime. Like B::Hooks::EndOfScope except it triggers for run-time instead of compile-time.
Example where it might be handy:
#!/usr/bin/perl use strict; use warnings; use Moose; ... # It would be nice not to need this.... __PACKAGE__->make_immutable;
MooseX/AutoImmute.pm
package MooseX::AutoImmute; use strict; use warnings; use Hook::AfterRuntime; sub import { my $class = shift; my $caller = caller; eval "package $caller; use Moose; 1" || die $@; after_runtime { $caller->make_immutable } } 1;
t/mytest.t
#!/usr/bin/perl use strict; use warnings; use MooseX::AutoImmute; .... #EOF # Package is now immutable autamatically
Does almost the same thing, except it is triggered after compile-time instead of run-time.
This module is part of the Fennec project. See Fennec for more details. Fennec is a project to develop an extendable and powerful testing framework. Together the tools that make up the Fennec framework provide a potent testing environment.
The tools provided by Fennec are also useful on their own. Sometimes a tool created for Fennec is useful outside the greator framework. Such tools are turned into their own projects. This is one such project.
The primary Fennec project that ties them all together.
Chad Granum exodist7@gmail.com
Copyright (C) 2010 Chad Granum
Hook-AfterRuntime is free software; Standard perl licence.
Hook-AfterRuntime is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
To install Hook::AfterRuntime, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hook::AfterRuntime
CPAN shell
perl -MCPAN -e shell install Hook::AfterRuntime
For more information on module installation, please visit the detailed CPAN module installation guide.