$doc = ''; open (MYOUT, ">/mypath/output.html") or die $!; $doc .= "

Mydata....

"; $doc .= "

Myotherdata....

"; print $doc; # This goes to the web browser print MYOUT $doc; # This goes to a files close (MYOUT);