Unless you need to write to each of the 30,000 files after each line of input, I'd have @array[30000][100], and push to each relevant array after input.
Once you have 100 records associated with an output file, I'd
- open the file to append
- write the 100 records
- flush and close the file
- recycle