my @array = qw(some data you want to print to a file); open(my $fh, '>', '/path/to/a/text/file.txt') || die "could not open output file : $!\n"; { local $, = "\n"; print $fh @array; } close($fh);