http://qs321.pair.com?node_id=1231045


in reply to Normalizing a range of numbers to a percentage

For such a simple translation it might be overkill but you could also use an interpolation module such as Math::Interpolate for the translation.

use strict; use warnings; use Math::Interpolate qw(linear_interpolate); print "$_: ".linear_interpolate( $_, [0,255], [0,100])."\n" for 0..255 +;