Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday December 16, 2004
07:37 PM

State machine stack traces

[ #22345 ]

Guess what this is:

State: installed
  message => undef,
  result => 1

State: version
  message => undef,
  result => '1'

That's part of a state machine stacktrace. This should be on the CPAN soon. David and I (mostly David) have put together a state machine module that's actually user friendly. Here is the definition of the first two states:

    my $fail    = sub {! shift->result };
    my $succeed = sub {  shift->result } ;
    my @state_machine = (
        installed => {
            on_enter => sub {
                my $machine = shift;
                $machine->set_message($self->app_name ." does not appear to be i
                  unless $machine->result;
            rules  => [
                fail    => $fail,
                version => $succeed,
        version => {
            on_enter => sub {
                my $machine = shift;
                unless ($machine->result) {
                    my $required = $self->build->_required_version;
                    my $actual   = $self->info->version;
                        . " required version $required but you have $actual");
            rules  => [
                fail       => $fail,
                createlang => $succeed,

David has already released FSA::Rules, , but with the new version that's being created, there will be a lot more power, including the stack traces shown. Frankly, I'm surprised that the machines currently available on the CPAN are not this useful. Now that I see how they work, I can't believe that I've not paid attention to them before. They make (some) complex tasks so much easier. I'll just have to avoid the temptation to reach for them when I don't need them.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.