logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Data::HexDump - Hexadecial Dumper

Author

       Fabien Tassin <fta@oleane.net>

Description

       This module will generate a hexadecimal dump of a data string or file.  You can either use the exported
       function, as shown in the SYNOPSIS above, or the OO interface, described below.

       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 is returned in a string.  Each line of the result consists of the offset in the source in the
       leftmost column of each line, followed by one or more columns of data from the source in hexadecimal.
       The rightmost column of each line shows the printable characters (all others are shown as single dots).

   FunctionalInterface
       This module exports a single function, "HexDump", which takes a scalar value and returns a string which
       contains the hexdump of the passed data.

   OOInterface
       You first construct a "Data::HexDump" object, then tell it where to get the data from, and 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 to the
       "data" method, then any subsequent calls to "fh()" or "file()" will have no effect.

Name

       Data::HexDump - Hexadecial Dumper

See Also

       Data::Hexify, by Johan Vromans, is another simple option, similar to this module. Last release in 2004.

       Data::Hexdumper (by David Cantrell, DCANTRELL) is 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.

Synopsis

       Functional interface:

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

       OO interface:

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

See Also