my $out_fh; open($out_fh, ">", "myfile.xml") or die "Cannot open myfile.xml - $!"; #### print {$out_fh} "Hello World!\n"; #### open(STDOUT,">","myfile.xml") or die "Cannot redirect STDOUT to myfile.xml - $!";