#!/usr/bin/perl use strict; use warnings; my @input = qw( a b c d ); open(my $fh, '>', "output.txt") or die "cannot open input file $!"; foreach(@input){ print $fh "$_ \n"; } close($fh);