open $fh, '>', 'somefile.html' or die "Can't open HTML file - $!"; #... do things here to generate $somestuff print $fh $somestuff;