in reply to Re^2: Desperatly seeking CSW (Class::Std Wisdom)
in thread Desperatly seeking CSW (Class::Std Wisdom)

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.