{ my %tags = ( a => \&anchor_handler, img => \&image_handler, frame => \&frame_handler, ); sub dispatcher { my ($self, $attributes, $tagname) = @_; if (exists $tags{$tagname}) { $tags{$tagname}->($self, $attributes); } } }