my $in_prefix = "K"; my $out_prefix = "K"; if ( $in_traffic < 1024 ) { $in_traffic = sprintf( "%.2f", $in_traffic / 1024 ); $in_prefix = "M"; } if ( $out_traffic < 1024 ) { $out_traffic = sprintf( "%.2f", $out_traffic / 1024 ); $out_prefix = "M"; } if ( $in_traffic > 1024 ) { $in_traffic = sprintf( "%.2f", $in_traffic / 1024 ); $in_prefix = "M"; } if ( $out_traffic > 1024 ) { $out_traffic = sprintf( "%.2f", $out_traffic / 1024 ); $out_prefix = "M"; } if ( $in_traffic > 1024 * 1024 ) { $in_traffic = sprintf( "%.2f", $in_traffic / 1024 * 1024 ); $in_prefix = "G"; } if ( $out_traffic > 1024 * 1024 ) { $out_traffic = sprintf( "%.2f",$out_traffic / 1024 * 1024 ); $out_prefix = "G"; }