- NAME
- SYNOPSIS
- DESCRIPTION
- COPYRIGHT
- SEE ALSO

# NAME

ActiveState::Bytes - Format byte quantities

# SYNOPSIS

     use ActiveState::Bytes qw(bytes_format bytes_parse);
     print "The file is ", bytes_format(-s $file), " long.\n";

     print "1 megabyte is ", bytes_parse('1m'), " bytes.\n";

# DESCRIPTION

The `ActiveState::Bytes` module provides functions for dealing with human readable byte strings.

$str = bytes_format( $n )

  This formats the number of bytes given as argument as a string using suffixes like "KB", "GB", "TB" to make it concise. The return value is a string like one of these:

         128 bytes
         1.5 KB
         130 MB

  Precision might be lost and there is currently no way to influence how precise the result should be. The current implementation gives no more than 3 digits of precision.

$bytes = bytes_parse( $str )

  Converts a bytes string ( "1m" ) into actually bytes. Lowercase units are in powers of 10, uppercase are in powers of 2. For example, 1K is 1024 bytes, 1k is 1000 bytes. Supports units are k, m, g, t, p, e, z, and y in ascending order.

# COPYRIGHT

Copyright (C) 2003 ActiveState Corp. All rights reserved.

# SEE ALSO

ActiveState::Duration