use strict; use warnings; package Monks::AttributeDispatcher; sub import { my $sPackage = shift @_; my %hDispatch = ( @_ ); print "caller=$caller dispatch=<@{[ %hDispatch ]}>\n"; my $sFetch = "${caller}::FETCH_CODE_ATTRIBUTES"; *{$sFetch} = sub { return keys %hDispatch; }; my $sModify = "${caller}::MODIFY_CODE_ATTRIBUTES"; *{$sModify} = sub { my $sPackage = shift @_; my $crSub = shift @_; foreach my $sAttribute (@_) { my $crAttribute = $hDispatch{$sAttribute}; #print STDERR "attribute=<$sAttribute> sub=<$crAttribute>\n"; &$crAttribute($sPackage, $crSub, $sAttribute) if defined($crAttribute); } return (); #indicate all attributes were handled } } return 1;