in reply to Keep file open for sub call?
my @lines; push @lines, "First line of text.\n"; # keep pushing lines of text into the array my $filepath = 'foo.txt'; open my $FOOFILE, '>>', $filepath or die "Couldn't open $filepath: $!" +; print $FOOFILE $_ for @lines; close $FOOFILE;
You could pass the array as a reference to your sub.
|
|---|