NAME
nameMe - and tell me my purpose so I don't realize I am a tool
SYNAPSIS
DESCRIPTION
METHODS
$perlsubpod =back
SEE ALSO
COPYRIGHT AND LICENSE
Same terms as perl itself.
AUTHOR
Rosie Tay Robert <???@??.????<gt>
};
return $perl;
}
sub _dump_subs { my ( $self, $symbols ) = @_;
my $perl = q{
##########
############
# | ##############
#CCC##|#Subroutines>>>####
# | ##############
############
##########
};
foreach my $sub (@$symbols) {
$perl .= qq/
sub $sub {
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 $sub: ELOH! Replace me, I am just placeholder!\\n};
# return \$scope, which will be passed to next subroutine
return \$scope;
}
/;
}
return $perl;
}
# # #### #
sub plan2noSS { my ( $self, %opts ) = @_; my $SS = $self->new(%opts);
my $pre = $SS->pre;
my $perl = qq{
use strict;
use warnings;
use feature 'state';
## intialize hash ref as container for global memory my \$GLOBAL = {}; my \$scope = { thing => 0, };
# Sub::Genius is not used, but this call list has been generated # using Sub::Genius::Util::plan2noSS, # # perl -MSub::Genius::Util -e 'print Sub::Genius::Util->plan2noSS(pre => q{$pre})' # };
my @symbols = $SS->{_regex}->as_pfa->as_nfa->as_dfa->alphabet;
foreach my $sub (@symbols) {
$perl .= qq{\$scope = $sub(\$scope);\n};
}
$perl .= $self->_dump_subs( \@symbols );
return $perl;
}
1;
NAME
Sub::Genius::Util - assortment of utility methods that might make dealing with creating programs using <Sub::Genius> a little more convenient.
SYNOPSIS
As a one-liner,
$ perl -MSub::Genius::Util -e 'print plan2perl("A&B&C&D")' > my-script.pl
In a script;
use Sub::Genius::Util ();
open my $fh, q{>}, q{./my-script.pl} or die $!;
print $fh Sub::Genius::Util->plan2perl(pre => 'A&B&C&D');
DESCRIPTION
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
.
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,
$ perl -MSub::Genius::Util -e 'print Sub::Genius::Util->plan2perl(pre => q{A&B&C&D})' > my-script.pl
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
.
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;
}
METHODS
subs2perl
Implemented to support the accompanying utility used for initialing a script with Sub::Genius.
plan2noSS
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.
$ perl -MSub::Genius::Util -e 'print Sub::Genius::Util->plan2noSS(pre => 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);
SEE ALSO
COPYRIGHT AND LICENSE
Same terms as perl itself.
AUTHOR
OODLER 577 <oodler@cpan.org<gt>
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 95:
You forgot a '=back' before '=head1'