in reply to Munging with a regex dispatch table

If you're worried about looks you could define a prototyped sub which takes a block, key, and the hash to which to add.

sub add_action (&\%$) { my( $code, $h, $key ) = @_; $h->{$key} = $code; } my %dispatch; add_action { do_something_with_foo } %dispatch => qr/foo/;

As an aside, you might want to look at Tie::RefHash which will keep the compiled regexen as keys rather than stringifying them (they'll get recompiled when you use them /$re/, but it's kinda inefficient).