in reply to Finding the length of an aray in a hash

Can I do this by using scalar on the hash value directly without creating the unecessary array?

Given the way the data is organized, you can avoid the temporary array by counting the number of commas in a (hash) value then adding 1.

Instead of

@array = split /,/, $cant_make_day{$elim_key}; $length = @array;
try   $length = 1 + $cant_make_day{$elim_key} =~ tr/,/,/; This assumes that you never allow an empty ("") value in your hash.

Replies are listed 'Best First'.
Re: Re: Finding the length of an aray in a hash
by tallus (Initiate) on Apr 21, 2002 at 01:59 UTC
    This appeals to me but I don't think I can avoid an empty hash - the optimal solution is a day which no one has any problems attending (no one == an empty hash)