Acme-FSM
view release on metacpan or search on metacpan
$item % 3 ? !0 : !1, $item
},
tturn => [ qw/ echo SAME / ],
fturn => [ qw/ bravo NEXT / ]
}
World of a difference.
Furthermore, if you dare, take a look at
F<t/process/quadratic.t> and F<t/process/sort.t>.
But better don't, those are horrible.
Now, illustration what I<$namespace> configuration parameter opens.
Classics:
my $bb = Acme::FSM->connect(
{ },
alpha => {
switch => sub {
shift % 42, ''
}
}
);
Illustrations below are heavily stripped for brevity
(Perlwise and B<A::F>wise).
Separate namespace:
package Secret::Namespace;
sub bravo_sn {
shift;
shift % 42, ''
}
package Regular::Namespace;
use Acme::FSM;
my $bb = Acme::FSM->connect(
{ namespace => 'Secret::Namespace' },
alpha => {
switch => 'bravo_sn'
}
);
Separate class:
package Secret::Class;
sub new { bless { }, shift }
sub bravo_sc {
shift;
shift % 42, ''
}
package Regular::Class;
use Secret::Class;
use Acme::FSM;
my $not_bb = Secret::Class->new;
my $bb = Acme::FSM->connect(
{ namespace => $not_bb },
alpha => {
switch => 'bravo_sc'
}
);
And, finally, B<A::F> implodes upon itself:
package Secret::FSM;
use parent qw/ Acme::FSM /;
sub connect {
my $class = shift;
my $bb = $class->SUPER::connect( @_ );
} # or just skip constructor, if not needed
sub bravo_sf {
shift;
shift % 42, ''
}
package main;
my $bb = Secret::FSM->connect(
{ namespace => '' },
alpha => {
switch => 'bravo_sf'
}
);
=cut
=head1 COPYRIGHT AND LICENSE
Original Copyright: 2008 Dale M Amon. All rights reserved.
Original License:
LGPL-2.1
Artistic
BSD
Original Code Acquired from:
http://www.cpan.org/authors/id/D/DA/DALEAMON/DMAMisc-1.01-3.tar.gz
Copyright 2012, 2013, 2022 Eric Pozharski <whynto@pozharski.name>
Copyright 2025 Eric Pozharski <wayside.ultimate@tuta.io>
GNU LGPLv3
AS-IS, NO-WARRANTY, HOPE-TO-BE-USEFUL
=cut
1
( run in 2.171 seconds using v1.01-cache-2.11-cpan-9581c071862 )