use warnings; use strict; sub output; my $data = [ 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 2, 2, 3, 34, 5, 6, 7, 8, 81 ]; output($data); sub output { open my $fh, '>>', "output.txt" or die $!; print $fh $_, $/ for @{ shift(@_) }; }