Build simple rules-based state machines in Perl