Lorenzo Caggioni am Freitag, 25. November 2005 11.04:
> Attached you can find the code an a input file to try it.
>
> I'm sorry if the code is not realy commented and if it is no real clear,
> but i have to delete some line because it is base on a database....
From a short view into the code, I see optimization potential
(some may have quite an effect, others may not...) in:
a) main::SplitRowByLength:
instead of substr, you could try and benchmark direct extraction of the fields
with a single regex along the lines my @fields=$line=~/(.{1})(.{4})/;
unpack may be better; not much experience with it.
b) in the top level while loop:
avoid the repeated eval (can't see a purpose for that...). I may have
overlooked something, but why
$xFieldValue = '($cdr[0]';
$xFieldValue .= ',[EMAIL PROTECTED],\$cdrsline,\$dbh)';
eval ("fmtTLGInternationalFormatTelegramTEST".$xFieldValue);
instead of a simple
fmtTLGInternationalFormatTelegramTEST($cdr[0],[EMAIL
PROTECTED],\$cdrsline,\$dbh)
(where the ref to $dbh is unneccessary since it is an object, and $cdr[0]
could be replaced by a preceeding my $cdr0=$cdr[0] and then use $cdr0)
?
Then, first make a my variable instead of using the same hash lookup several
times. F.i $globalParameters{"OutputFileFieldDelimiter"} is used many times.
c) generally
Avoid most of the string interpolation where not necessary (hash keys, around
integers, left from '=>' etc.)
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.
e) fmtTLGConvertDateTEST
here the many substr could be avoided
Since I'm still a beginner, be carful with my advices...
hopefully at least 2 cents,
joe
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>