Very crude, but you can expand on it. It is basic math.
sub toKbytes {
my $bytes = shift;
return $bytes / 1024;
}
sub toMbytes {
my $bytes = shift;
return $bytes / (1024 * 1024);
}
Then you can do:
print toMbytes(1048576), "\n";
print toKbytes(1048576), "\n";
You'll also want to read up on
sprintf or
printf if you want to round off the return values.
Error: Keyboard not attached. Press F1 to continue.