Aion-Spirit
view release on metacpan or search on metacpan
[](https://github.com/darviarush/perl-aion-spirit/actions)
# NAME
Aion::Spirit - functions for controlling the program execution process
# VERSION
0.0.1
# SYNOPSIS
```perl
use Aion::Spirit;
package A {
sub x_1() { 1 }
sub x_2() { 2 }
sub y_1($) { 1+shift }
sub y_2($) { 2+shift }
}
aroundsub "A", qr/_2$/, sub { shift->(@_[1..$#_]) + .03 };
A::x_1 # -> 1
# Perl cached subroutines with prototype "()" in main:: as constant. aroundsub should be applied in a BEGIN block to avoid this:
A::x_2 # -> 2
(\&A::x_2)->() # -> 2.03
# Functions with parameters not cached:
A::y_1 .5 # -> 1.5
A::y_2 .5 # -> 2.53
```
# DESCRIPTION
A Perl program consists of packages, globals, subroutines, lists, and scalars. That is, it is simply data that, unlike a C program, can be âchanged on the fly.â
Thus, this module provides convenient functions for transforming all these entities, as well as maintaining their integrity.
# SUBROUTINES
## aroundsub ($pkg, $re, $around)
Wraps the functions in the package in the specified regular sequence.
The package may not be specified for the current:
File N.pm:
```perl
package N;
use Aion::Spirit qw/aroundsub/;
use constant z_2 => 10;
aroundsub qr/_2$/, sub { shift->(@_[1..$#_]) + .03 };
sub x_1() { 1 }
sub x_2() { 2 }
sub y_1($) { 1+shift }
sub y_2($) { 2+shift }
1;
( run in 1.228 second using v1.01-cache-2.11-cpan-99c4e6809bf )