in reply to Re: Hash key counting
in thread Hash key counting

The explanation of what I'm trying to do is going to be somewhat unclear, it is part of a database handler which parses output and creates HTML tables based on user selections. The %columns hash contains descriptors which (if valid) are parsed and a table is put together at a later time.

I have gone over the logic, the @discounts array contains a number of elements which have either a value of 0 or 1. If the current element has a value of 1, then count how many keys are in columns.

%columns = ( 1 => 1, 2 => 1, 3 => 1, 4 => 1 );


In this case, I ask for how many keys are in %column, increment by one and move forward, so the above should return 4 += 1 = 5.

Then assign:

$columns{5} = 1;

Loop again, return a count of 5, increment and assign:

$key_num = keys %columns # 5 $key_num++; # 6 $columns{6} = 1;


Is that a little more clear?

BlackJudas