P is for Practical | |
PerlMonks |
Re: Optimization of scriptby Cristoforo (Curate) |
on Aug 18, 2016 at 20:48 UTC ( [id://1170024]=note: print w/replies, xml ) | Need Help?? |
Like ww said, the post is pretty long to try to analyze and I can't comment on the correctness of the wooksheets you're creating.
I'm assuming the accounts in the control file are in the same order in the csv files and that the records matching the 'AccountInProcess' in the csv files are one sfter the other (if there are more than 1 record in the csv file matching the 'AccountInProcess'). I think the the seek statements are wrong and they may be the reason for the slow down. They are seeking backwards more than 1 line.
I think you need This version of seek will position the file to start reading on the line immediately after the last successful match which is what you want. Your seek moves it way back to near the beginning of the file. So, you are effectively rereading the whole file from the beginning each time. There are a few items in your program that could be improved. These variables could all be declared as scalars instead of declared as arrays. You don't use them as arrays in your program anyway. So you could say, for instance, $found_calendario_pago = 0; instead of $found_calendario_pago[0] = 0;. (The same for all the other counters and flags.) Declared like this, instead:
In Section
Seekers of Perl Wisdom
|
|