Code-Splice
view release on metacpan or search on metacpan
lib/Code/Splice.pm view on Meta::CPAN
The body of the C<< code { } >> block are extracted from the subroutine and inserted in a place
in the code specified by the call to the C<splice()> function.
Where the new code is spliced in, the old code is spliced out.
The C<package> and C<method> arguments are required and tell the thing how to find the
code to be modified.
The C<code> argument is required as it specifies the code to be spliced in.
That same code block should not be used for anything else under penalty of coredump.
The rest of the argumets specify where the code is to be inserted.
Any number of C<precondition> and C<postcondition> arguments provide callbacks
to help locate the exact area to splice the code in at.
Before the code can e spliced in, all of the C<precondition> blocks must have returned
true, and none of the C<postcondition> blocks may have yet returned true.
If a C<postcondition> returns true before all of the C<precondition> blocks have,
an error is raised.
Both blocks get called numerous times per line and get passed a reference to the C<B> OP object currently under consideration
and the text of the current line:
precondition => sub {
my $op = shift;
( run in 0.578 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )