I made some changes in the program (delete eval, edjust subs... ) Now the program takes less then 3 sec but it loses all the structure...
The main thing that increase performance is delete the eval("fun name"). I do it in this way because the name of the function is retrived from a database. is there another way to recal a function retrining his name from a variable? Any suggestions? Thanks On 11/25/05, John Doe <[EMAIL PROTECTED]> wrote: > > Rob Coops am Freitag, 25. November 2005 14.13: > > Making the subs shorter will maybe help a little in the speed of > processing > > but it will make it a lot more difficult for the person that gets to > take > > over the maintanace. When you know what you are doing and why it is easy > to > > read it, but when you get a big program written like that and are asked > to > > support it... you will go looking for the guy that wrote it and give him > a > > good old kick in the .... because of all the headache he cost you. > > So unless this is a very personal script that will not ever be handed > over > > to anyone and your memory is good enough to remember what you are doing > > where and why please make sure you do not write subs like that unless > you > > are very good at documenting your code as you are writting it. > > Hi Rob > > [see inline] > > > On 11/25/05, John Doe <[EMAIL PROTECTED]> wrote: > > > Lorenzo Caggioni am Freitag, 25. November 2005 11.04: > > > > Attached you can find the code an a input file to try it. > > > > > [...] > > > d) shorten some subs > > > > > > sub fmtCurrencyCodeTEST { > > > my($xCurr) = "EUR"; > > > return $xCurr; > > > } > > > => > > > sub fmtCurrencyCodeTEST {'EUR'} > > > > > > sub fmtTLGATTR2_int_natTEST { > > > my ($xServiceCode,$xInputCDR) = @_; > > > return $xInputCDR->[20]; > > > } > > > => > > > sub fmtTLGATTR2_int_natTEST {$_[1]->[20]} > > > > > > etc. > [...] > > Ok, making subs shorter with less local variables won't improve > performance > significantly. That's why a listed it at the end :-) > > Concerning bad maintanability, I don't see much problems in my examples, > since > there is no obfuscating of algorithms and such, but only direct access to > the > arguments - the difference is not very big. > > And of course a sub should be documented: > - purpose > - side effects > - parameter description > - description of the return values > - (etc.) > > Compare: > > # purpose: return currency > # in: -- > # out: constant string 'EUR' > # > sub fmtCurrencyCodeTEST { > my($xCurr) = "EUR"; > return $xCurr; > } > > # purpose: return currency > # in: -- > # out: constant string 'EUR' > # > sub fmtCurrencyCodeTEST {'EUR'} > > In this example, you could even omit the comments, since it's obvious > what's > the purpose of the sub. > > > Have a look into the perl source; you will find lots of such examples. > > greetings, > > joe > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > >