$ perl -wle'my @a = qw(a b c d); open IN, ">data.txt" or die $!; print @a; print IN @a; close IN; ' abcd $ cat data.txt abcd