open my $out_fh, '>', 'filename.txt' or die $!; print $out_fh @output; close $out_fh or die $!;