I am not getting the same error when I run this code:
{
package My::Class;
{
use strict;
use Class::Std;
my %_handler_map :ATTR; # Holds trigger names and states.
# ... further down
# ==============================================================
+=============
# METHOD: register_handler(%registration_hash)
# REQUIRES: A hash with the following parameters ...
# trigger: The state which triggers the handler.
# handler: The name space string (Triggered::Handler) which i
+s triggered.
# RETURNS:
# true: If the trigger and handler both are present and are s
+tored.
# false: If the trigger or handler are not valid (present).
# other: An error is thrown if the trigger and handler are val
+id but
# but they do not get stored.
#
# PURPOSE: Register state handlers and triggers.
# --------------------------------------------------------------
+-------------
sub register_state
{
my ($self, %arguments) = @_;
my $trigger = $arguments{'trigger'} || return(undef());
my $handler = $arguments{'handler'} || return(undef());
# ... Here is the part I am having problems with.
$_handler_map{ident($self)}{$trigger} = $handler;
# Do error checking here. Throw an error if needed.
return(1);
}
}
}
my $state_arguments = { 'form_data' => {} };
my $state_manager = My::Class->new($state_arguments);
$state_manager->register_state(
'trigger' => 'welcome',
'handler' => 'Handler::Welcome',
)
Which seems to confirm my suspicion that the problem is elsewhere in your class. The error you are tripping in Class::Std is in one of the (IMHO) darker corners of the module. Something as simple as what you have demonstrated in the OP should not be causing that error. Perhaps if you posted your entire class, the issue might be more obvious to spot.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|