Write Lines to a File in Perl
Open a file for writing and emit several lines, then close cleanly.
Author:
chris
// Language: Perl
#!/usr/bin/perl
use strict;
use warnings;
my @lines = ("alpha", "beta", "gamma");
open(my $fh, '>', 'out.txt') or die "Cannot write: $!";
print {$fh} "$_\n" for @lines;
close($fh);