in reply to I'm drowning in coderefs in my HTML element module

Your formatting standards are probably not optimal for this situation. I have taken the liberty to reformat it somewhat. Also I would propose to change the order always to header - content - footer which makes it a bit more readible as well (unless this has an impact on the output?).

You can also avoid deep nesting by naming a few of the code refs and define them separately.

Here is an illustration of what I mean, I hope this helps.

# non-standard formatting ############################################ +############################# # always put footer at the end (assuming order does not matter?) body( header => sub { hgroup( sub { }); }, contents => sub { article( header => sub { }, contents => sub { section( header = +> sub { }, contents = +> sub { aside( header => sub { }, + contents => sub { }, + footer => sub { }, ); }, footer = +> sub { }, ); section( header = +> sub { }, contents = +> sub { }, footer = +> sub { }, ); aside( header = +> sub { }, contents = +> sub { }, footer = +> sub { }, ); }, footer => sub { }, ); }, footer => sub { address( sub { }); }, ); # alternative ######################################################## +############################# # remaining super-structure body( header => sub { hgroup( sub { }); }, contents => sub { article( header => sub { }, contents => \&contents1, footer => sub { }, ); }, footer => sub { address( sub { }); }, ); # delegated content sub contents1 { section( header => sub { }, contents => sub { aside( header => sub { }, contents => sub { }, footer => sub { }, + ); }, footer => sub { }, ); section( header => sub { }, contents => sub { }, footer => sub { }, ); aside( header => sub { }, contents => sub { }, footer => sub { }, ); }