(Warning: awkmonk post ahead): I almost forgot. I once had a similar problem, so I wrote an awk solution. Though in my case, I knew there were only about 5 different values for the file name, and there was a bit more error checking than this, but it was basically something like:
#!/usr/bin/awk -f { print $1, $3>>$2 }
And just use a2p to get a perl version of this :)

In reply to Re: Performance Trap - Opening/Closing Files Inside a Loop by runrig
in thread Performance Trap - Opening/Closing Files Inside a Loop by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":