in reply to doing the same thing but with less code

Determining whether or not code can be shortened requires you to look at what is repeated and what differs between each repetition. Then you can simply write a subroutine to which you pass these differences or you can collect the information you need within some sort of data structure and iterate over it. In this particular case, you could actually just use POSIX's log10 function on $score to get its power of 10 and from there just figure out the powers above and below it. Please note that in the case where log10($score) < -99 that you should probably just say E = 0 (since log10(0) = -Inf). If you get stuck along the way, feel free to post code and ask for help in troublshooting.

Hope this helps.

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1

  • Comment on Re: doing the same thing but with less code