title: How can I convert a number to its multiple form in Perl?
body: <p>Do you know an easy and straight-forward method/sub/module which allows me to convert a number (say 1234567.89) to an easily readable form - something like 1.23M?</p>
  
  <p>Right now I can do this by making several comparisons, but I'm not happy with my method:</p>
  
  <pre><code>if($bytes &gt; 1000000000){ 
     $bytes = ( sprintf( "%0.2f", $bytes/1000000000 )). " Gb/s";                   
  }
  elsif ($bytes &gt; 1000000){       
     $bytes = ( sprintf( "%0.2f", $bytes/1000000 )). " Mb/s"; 
  }
  elsif ($bytes &gt; 1000){
     $bytes = ( sprintf( "%0.2f", $bytes/1000 )). " Kb/s"; 
  }
  else{ 
     $bytes = sprintf( "%0.2f", $bytes ). "b/s";
  }                                                                  
  </code></pre>
  
  <p>Thank you for your help!</p>