Per your request, I am going to focus on how to leverage Perl to make this script run quickly. There are a lot of little stylistic things that would make the code both shorter and more legible. I'm not the style police, though, and won't offer stylistic advice unless you would like to have it.
Looking at your implementation, your code only makes sense if you are working on accounts that have already been sorted by account number. If that's not the case, then I can't see how this would work at all. Furthermore, the control file would contain a subset of accounts to transfer (otherwise you wouldn't be looping through rows in LoanAccountFileHandle) and each account is associated with only one loan, or the control file has multiple lines repeating the same account number, one for each loan. This seems like a brittle approach, but who cares, it's a one-time transition script, and presumably you have a robust method for creating the control file.
With those assumptions in place, it looks to me like your algorithm should scale roughly linearly with the number of lines processed. Why would it slow down? The only thing I can come up with is that you're hitting memory issues on your machine. This could arise because either the Excel writer or the CSV reader are leaking memory (not that they're intrinsically leaky, it's just my guess). When your script is running, what does the RAM consumption look like?
In reply to Re: Optimization of script
by dcmertens
in thread Optimization of script
by JulioRD
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |