How do I use File::Slurp to write an array to a file with newlines?

Viewed 1986

I am using File::Slurp to write to a file. The problem is that the array elements are being written as a single string on one line. I would like to print array elements on separate lines.

I can always format my array elements to have a newline in each element, which I don't want to do.

Does File::Slurp support any options to print array elements on separate lines? I don't find any options in the documentation.

use File::Slurp;
my @input = ();

push (@input, "1:2");
push (@input, "a:b");

write_file("./out", @input);

Output looks like this

1:2a:b

I want

1:2
a:b
3 Answers
Related