1 package Devel::BeginLift;
7 our $VERSION = 0.001000;
10 use base qw(DynaLoader);
12 bootstrap Devel::BeginLift;
15 my ($class, @args) = @_;
17 $class->setup_for($target => \@args);
23 $class->teardown_for($target);
27 my ($class, $target, $args) = @_;
29 $lift{$target}{$_} = 1 for @$args;
33 my ($class, $target) = @_;
34 delete $lift{$target};
40 Devel::BeginLift - make selected sub calls evaluate at compile time
44 use Devel::BeginLift qw(foo baz);
50 sub foo { "foo: $_[0]\n"; }
52 sub bar { "bar: $_[0]\n"; }
75 Devel::BeginLift 'lifts' arbitrary sub calls to running at compile time
76 - sort of a souped up version of "use constant". It does this via some
77 slightly insane perlguts magic.
81 use Devel::BeginLift qw(list of subs);
83 Calls Devel::BeginLift->setup_for(__PACKAGE__ => \@list_of_subs);
89 Calls Devel::BeginLift->teardown_for(__PACKAGE__);
93 Devel::BeginLift->setup_for($package => \@subnames);
95 Installs begin lifting magic (unless already installed) and registers
96 "${package}::$name" for each member of @subnames to be executed when parsed
97 and replaced with its output rather than left for runtime.
101 Devel::BeginLift->teardown_for($package);
103 Deregisters all subs currently registered for $package and uninstalls begin
104 lifting magic is number of teardown_for calls matches number of setup_for
109 Matt S Trout - <mst@shadowcatsystems.co.uk>
111 Company: http://www.shadowcatsystems.co.uk/
112 Blog: http://chainsawblues.vox.com/
116 This library is free software under the same terms as perl itself