[ABE.pm] My first en^H^Hclosure doesn't work. :-(

Walt Mankowski waltman at pobox.com
Fri Oct 26 13:34:32 PDT 2007


On Fri, Oct 26, 2007 at 04:25:40PM -0400, Faber J. Fedor wrote:
> The reason for the *example* is I didn't want to say "I want to
> reimplement this if-elsif construct' then show my code that checks
> only the upper range and have someone go "where's the elsif?".

So instead you have people wondering why you have code there you don't
need which is just making everything that much harder.

> I like hashes?
> 
> Actually, what I implemented is very close to that:
> 
>     foreach my $key (sort { $b <=> $a } keys %costCalcH) {
>     return $costCalcH{$key} if $capt >= $key;
>     }
> 
> the main difference being I don't trust my user to put the values in
> proper order.

I was originally going to do that with hashes, but I didn't want the
overhead of having to sort the keys on every call.  Perhaps you could
have a preprocessing step where on the first call you generate a
sorted list from the hash?  Speaking of which, you don't trust them to
sort values, but you do trust them to enter perl hashes in the correct
syntax?

> And the original question remains...

Guess I'm less interested in the original question since if can be
solved in 2 lines of code in the alternate approach... :)

Walt


More information about the ABE-pm mailing list