sub table (&) { print-"\n"; shift->(); print "
\n"; sub row (&) { print ""; shift->(); print "\n"; } sub cell { print "$_" for @_; } table { row { cell "foo" } }; my $html = ""; open my $fh, '>>', \$html; select $fh; table { row { cell "foo" } }; close $fh; $html .= "";