our $print = sub { print shift }; sub table (&) { $print->("\n"); shift->(); $print->("
\n"); } sub row (&) { $print->(""); shift->(); $print->("\n"); } sub cell { $print->("$_") for @_; } table { row { cell "foo" } }; my $html = ""; local $print = sub { $html .= shift }; table { row { cell "foo" } }; $html .= ""; #### 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 .= "";