Data::Hexdumper provides a simple way to format arbitrary binary data
into a nice human-readable format, somewhat similar to the Unix hexdump
utility.

It gives the programmer a considerable degree of flexibility in how the
data is formatted, with sensible defaults. It is envisaged that it will
primarily be of use for those wrestling alligators in the swamp of binary
file formats, which is why it was written in the first place.

Does everything. Takes a hash of parameters, one of which is mandatory,
the rest having sensible defaults if not specified. Available parameters
are:

data

A scalar containing the binary data were interested in. This is
mandatory.

start_position

An integer telling us where in data to start dumping. Defaults to the
beginning of data.

end_position

An integer telling us where in data to stop dumping. Defaults to the
end of data.

number_format

This is deprecated. See INCOMPATIBLE CHANGES below. If you use this
your data will be padded with NULLs to be an integer multiple of 16 bytes.
You can expect number_format to be removed at some point in 2014 or later.

A string specifying how to format the data. It can be any of the following,
which you will notice have the same meanings as they do to perls pack
function:

C - unsigned char

S - unsigned 16-bit, native endianness

v or S< - unsigned 16-bit, little-endian

n or S> - unsigned 16-bit, big-endian

L - unsigned 32-bit, native endianness

V or L< - unsigned 32-bit, little-endian

N or L> - unsigned 32-bit, big-endian

Q - unsigned 64-bit, native endianness

Q< - unsigned 64-bit, little-endian

Q> - unsigned 64-bit, big-endian

Note that 64-bit formats are *always* available,
even if your perl is only 32-bit. Similarly, using < and > on
the S and L formats always works, even if youre using a pre 5.10.0 perl.
Thats because this code doesnt use pack().

output_format

This is an alternative and much more flexible (but more complex) method
of specifying the output format. Instead of specifying a single format
for all your output, you can specify formats like:

%4a : %C %S %L> %Q : %d

which will, on each line, display first the address (consisting of 0x
and 4 hexadecimal digits, zero-padded if necessary), then a space, then
a colon, then a single byte of data, then a space, then an unsigned
16-bit value in native endianness, then a space, then an unsigned 32-bit
big-endian value, ... then a colon,
a space, then the characters representing your 15 byte record.

You can use exactly the same characters and character sequences as are
specified above for number_format, plus a for the address, and d
for the data. To output a literal % character, use %% as is normal
with formats - see sprintf for details. To output a literal < or >
character where it may be confused with any of the {S,L,Q}{<,>}
sequences, use %< or %>. So, for example, to output a 16-bit
value in native endianness followed by <, use %S%<.

%a takes an optional base-ten number between the % and the a signifying
the number of hexadecimal digits. This defaults to 4.

%{C,S,L,Q} also take an optional base-ten number between the % and the letter,
signifying the number of repeats. These will be separated by spaces in
the output. So %4C is equivalent to %C %C%C%C.

Anything else will get printed literally. This format
will be repeated for as many lines as necessary. If the amount of data
isnt enough to completely fill the last line, it will be padded with
NULLbytes.

To specify both number_format and output_format is a fatal error.

If neither are given, output_format defaults to:

%4a : %16C : %d

which is equivalent to the old-style:

number_format => C

suppress_warnings

Make this trueif you want to suppress any warnings - such as that your
data may have been padded with NULLs if it didnt exactly fit into an
integer number of words, or if you do something that is deprecated.

space_as_space

Make this trueif you want spaces (ASCII character 0x20) to be printed as
spaces Otherwise, spaces will be printed as full stops / periods (ASCII
0x2E).

Alternatively, you can supply the parameters as a scalar chunk of data
followed by an optional hashref of the other options:

The best bug reports contain a test file that fails with the current
code, and will pass once it has been fixed. The code repository
is on Github:
<git://github.com/DrHyde/perl-modules-Data-Hexdumper.git>

This software is free-as-in-speech software, and may be used,
distributed, and modified under the terms of either the GNU
General Public Licence version 2 or the Artistic Licence. Its
up to you which one you use. The full text of the licences can
be found in the files GPL2.txt and ARTISTIC.txt, respectively.