use lib "./blib/lib"; # create new object with operator overloading activated use String::Divert; my $html = new String::Divert; $html->overload(1); # generate outer HTML framework $html .= "\n" . " \n" . " " . $html->folder("head") . " \n" . " \n" . " " . $html->folder("body") . " \n" . "\n"; $html >> "body"; # generate body $html .= "\n" . " \n" . " \n" . " \n" . " \n" . "
\n" . " " . $html->folder("left") . " \n" . " " . $html->folder("right") . "
\n"; # generate header $html >> "head"; $html .= "foo\n"; $html << 1; # generate left contents $html >> "left"; $html .= "bar1\n" . "bar2\n"; $html << 1; # generate right contents $html >> "right"; $html .= "quux1\n" . "quux2\n"; $html << 1; # undivert all diversions and output unfolded HTML $html << 0; print $html; # destroy object $html->destroy;