in reply to Write large array to file, very slow
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Write large array to file, very slow
by Eily (Monsignor) on Aug 20, 2018 at 14:35 UTC | |
by hippo (Archbishop) on Aug 20, 2018 at 15:24 UTC | |
by Eily (Monsignor) on Aug 20, 2018 at 16:14 UTC | |
by hippo (Archbishop) on Aug 20, 2018 at 18:11 UTC | |
by Eily (Monsignor) on Aug 21, 2018 at 08:29 UTC | |
|