foreach (@mergedlogs) { open FH, ">>mergedlogs.txt" or die "can't open mergedlogs.txt: $!"; print FH "$_\n"; close FH }
You are opening and closing the file on every single record. Don't do that. Instead:
open FH, ">>mergedlogs.txt" or die "can't open mergedlogs.txt: $!"; $| = 0; # just in case foreach (@mergedlogs) { print FH "$_\n"; } close FH;
There are other ways this could be improved, but this should get you a large gain for little effort.
In reply to Re: Write large array to file, very slow
by hippo
in thread Write large array to file, very slow
by junebob
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |