⭐ in reply to How do I write to a file?
The 3-arg form of open is fairly useful to prevent problems with filenames "tricking" perl, and other nasty surprises:
open FH, ">", $outfile or die "Error writing '$outfile': $!\n"; print FH $output; close FH;
Also useful are lexical filehandles:
open my $filehandle, ">", $outfile or die "Error writing '$outfile': $ +!\n"; print $filehandle $output; close $filehandle;
In Section
Seekers of Perl Wisdom