您是否知道一种简单直接的方法/子/模块,它允许我将数字(例如 1234567.89)转换为易于阅读的形式 - 例如 1.23M?
现在我可以通过多次比较来做到这一点,但我对我的方法不满意:
if($bytes > 1000000000){
$bytes = ( sprintf( "%0.2f", $bytes/1000000000 )). " Gb/s";
}
elsif ($bytes > 1000000){
$bytes = ( sprintf( "%0.2f", $bytes/1000000 )). " Mb/s";
}
elsif ($bytes > 1000){
$bytes = ( sprintf( "%0.2f", $bytes/1000 )). " Kb/s";
}
else{
$bytes = sprintf( "%0.2f", $bytes ). "b/s";
}
感谢您的帮助!