krisahoch has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monks,
After spending much time trying to figure out something (which I should not need help figuring out), I am bringing my problem to y'all (not from Texas, just live here).
I am having an issue trying to add a value to a variable. The variable is defined as per the documentation (see below). The main issue here is that I am storing a hash in the variable, and I want to be able to assign keys to the hash via class method (see below).
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 is tr +iggered. # RETURNS: # true: If the trigger and handler both are present and are store +d. # false: If the trigger or handler are not valid (present). # other: An error is thrown if the trigger and handler are valid b +ut # 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); } } 1;
The error that I am getting is as follows ...
Can't make anonymous subroutine cumulative at <blah>
Is there something that I have overlooked in the Class::Std documentation?
Thank you in advance for your time,
Kristofer Hoch
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Desperatly seeking CSW (Class::Std Wisdom)
by stvn (Monsignor) on Aug 08, 2006 at 14:08 UTC | |
by krisahoch (Deacon) on Aug 08, 2006 at 14:52 UTC | |
by stvn (Monsignor) on Aug 08, 2006 at 15:19 UTC | |
by krisahoch (Deacon) on Aug 08, 2006 at 20:30 UTC |