Sub::Genius::Util - Helper module for dumping Perl code
This is implemented for use with stubby, please look at that script to see how it's used.
Useful for dumping a Perl code for starting a module or script that implements the subroutines that are involved in the execution of a plan.
plan
Given a PRE, dumps a Perl script with the subroutines implied by the symbols in the PREs as subroutines. It might be most effective when called as a one liner,
This could get unweildy if you have a concurrent model in place, but anyone reviewing this POD should be able to figure out the best way to leverage plan2perl.
plan2perl
Each subroutine takes the approximate form,
sub C { my $scope = shift; # execution context passed by Sub::Genius::run_once state $mystate = {}; # sticks around on subsequent calls my $myprivs = {}; # reaped when execution is out of sub scope #-- begin subroutine implementation here --# print qq{Sub C: ELOH! Replace me, I am just placeholder!\n}; # return $scope, which will be passed to next subroutine return $scope; }
subs2perl
Implemented to support the accompanying utility used for initialing a script with Sub::Genius.
plan2nodeps
Given a PRE, dumps a Perl script that can be run without loading Sub::Genius by providing explicit calls, that also pass along a $scope variable.
$scope
$ perl -MSub::Genius::Util -e 'print Sub::Genius::Util->plan2nodeps(plan => q{A&B&C&D&E&F&G})' > my-script.pl # does explicitly what Sub::Genius::run_once does, give a sequentialized plan # generated from the PRE, 'A&B&C&D&E&F&G' my $scope = { }; $scope = G($scope); $scope = D($scope); $scope = F($scope); $scope = B($scope); $scope = E($scope); $scope = H($scope); $scope = C($scope); $scope = A($scope);
Sub::Genius
Same terms as perl itself.
OODLER 577 <oodler@cpan.org>
To install Sub::Genius, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Genius
CPAN shell
perl -MCPAN -e shell install Sub::Genius
For more information on module installation, please visit the detailed CPAN module installation guide.