Is there a good reason you're not doing this in VB inside Excel vs. trying to do it in Perl?
How are you extracting the data from the Excel file? Is this the problem step?
If you have the data extacted, maybe with Spreadsheet::ParseExcel, then the problem can be reduced to "I have this data structrure and I need to iterate through it, grabbing various bits identified by (insert rules here)."
Figure out where the problem is and solve that, then go to the next step. It sounds to me that you haven't fully analyzed what the steps are to solving your problem.
My criteria for good software:
Does it work?
Can someone else come in, make a change, and be reasonably certain no bugs were introduced?