If that is the case - combine the two methods.
- Buffer the strings up to say 10k or more.
- Once they hit that size - look for an open, or cache a new filehandle.
- Print out the buffered string for the file and clear the buffer.
- Finish off by flushing remaining buffers.
my @a=qw(random brilliant braindead); print $a[rand(@a)];