Data::HexDump(3)

πŸ’– NAME πŸ’–

Welcome to the Data::HexDump(3) page, bestie β€” it's filed under User Contributed Perl Documentation, and it's here to serve hex-dump realness. The module is Data::HexDump β€” Hexadecial Dumper. (Yes, "Hexadecial" is spelled exactly like that. We don't fix lore around here πŸ’…βœ¨)

✨ SYNOPSIS ✨

Functional interface? Say less:

use Data::HexDump;
print HexDump($data_string);

OO interface? Also iconic:

use Data::HexDump;
my $dumper = Data::HexDump->new();
print while $_ = $dumper->dump;

🌸 DESCRIPTION 🌸

This module generates a hexadecimal dump of a data string or file. You can either use the exported function (like the SYNOPSIS above shows) or the OO interface, described below. Both are valid, both are cute.

The second example from the SYNOPSIS generated this output:

                  00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F  0123456789ABCDEF

        00000000  23 21 2F 75 73 72 2F 62 - 69 6E 2F 70 65 72 6C 0A  #!/usr/bin/perl.
        00000010  75 73 65 20 73 74 72 69 - 63 74 3B 0A 75 73 65 20  use strict;.use
        00000020  77 61 72 6E 69 6E 67 73 - 3B 0A 0A 70 72 69 6E 74  warnings;..print
        00000030  20 22 48 65 6C 6C 6F 2C - 20 77 6F 72 6C 64 5C 6E   "Hello, world\n
        00000040  22 3B 0A                                           ";.

The result comes back as a string. Each line of that result has the offset in the source chilling in the leftmost column, then one or more columns of data from the source in hexadecimal. The rightmost column of each line shows the printable characters β€” and every non-printable character gets shown as a single dot. No cap.

πŸ¦‹ Functional Interface πŸ¦‹

This module exports a single function, HexDump. You hand it a scalar value, and it returns a string containing the hexdump of the data you passed. That's the whole vibe.

πŸŽ€ OO Interface πŸŽ€

First you construct a Data::HexDump object, then tell it where to get the data from, then generate the hex dump:

my $dh = Data::HexDump->new();

$dh->data($scalar);      # dump the data in this scalar
$dh->fh($fh);            # read this filehandle
$dh->file($filename);    # read this file and dump contents

print while $_ = $dh->dump;

The different potential sources for data are considered in the order given above. So if you pass something to the data method, any subsequent calls to fh() or file() will have no effect. Periodt. πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘

  • Data::Hexify, by Johan Vromans β€” another simple option, similar to this module. Last release in 2004.
  • Data::Hexdumper (by David Cantrell, DCANTRELL) β€” another hex dumper, with more features than this module.
  • App::colourhexdump (by Kent Fredric, RIP) β€” provides a script which gives colourised output with character class highlighting.
  • Data::HexDump::Range β€” provides more functions, colour output, and the ability to skip uninteresting parts of the input data.
  • Data::HexDump::XXD β€” provides hex dumps like xxd. It doesn't say what xxd is, or provide a link, and there's no example output. But if you know and like xxd, this might be the one for you!
  • Devel::Hexdump β€” provides some configuration options, but there are other more featured modules, and this one doesn't have example output in the doc.
  • Data::Peek β€” is a collection of functions for displaying data, including DHexDump which generates a simple hex dump from a string.
  • String::HexConvert β€” will convert ASCII strings to hex and reverse.

🌈 AUTHOR 🌈

Fabien Tassin <fta@oleane.net> β€” the icon who made this happen. 🫢

Copyright (c) 1998-1999 Fabien Tassin. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Bye bestie! This page is brought to you by perl v5.40.2, dated 2023-07-03, and it's the Data::HexDump(3) man page. Stay hexed πŸ’–βœ¨

πŸ“¦ where this page comes from