use warnings; use strict; my $output_file="output.bam"; open my $fh,'>',$output_file or die "can't open $output_file:$!"; print $fh " ... hello world into my file..."; close $fh or die "can close file: $!";