open(my $OUTPUT, '+>>', "my file.txt") or die $!; if (@array) { print $OUTPUT "@array"; } if (@array2) { pprint $OUTPUT "@array2"; }