John W. Krahn wrote:
> Frank Bax wrote:
>>Rather than create/store/sort many billion entities, my script creates
>>these entities dynamically and maintains a hash of the "top 100".  As
>>each entity is created, I search my hash for the entity with "lowest"
>>value, based on a number of elements in the hash; then "low" element
>>gets replaced with "new" element.  Code looks like:
>>    my $low = 0;
>>    for( my $new=1; $new<=$iSuit; ++$new ) {
>>        my $snew =
>>sprintf("%4d%4d",$aSuit{$new}{'rescap'},$aSuit{$new}{'resval'});
>>        my $slow =
>>sprintf("%4d%4d",$aSuit{$low}{'rescap'},$aSuit{$low}{'resval'});
> 
> Using sprintf() to concatenate numbers is (AFAIK) going to be slower than
> concatenation:
> 
>         my $snew = $aSuit{ $new }{ rescap } . $aSuit{ $new }{ resval };
>         my $slow = $aSuit{ $low }{ rescap } . $aSuit{ $low }{ resval };

Sorry, that won't work because of the '%4d' format but this should:

       my $snew = $aSuit{ $new }{ rescap } * 10000 + $aSuit{ $new }{ resval };
       my $slow = $aSuit{ $low }{ rescap } * 10000 + $aSuit{ $low }{ resval };



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to