Data::HexDump3pm
Hexadecial dumper
Usage
Functional interface:
use Data::HexDump;print HexDump($data_string);
OO interface:
use Data::HexDump;my $dumper = Data::HexDump->new();print while $_ = $dumper->dump;
Overview
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 0123456789ABCDEF00000000 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;.use00000020 77 61 72 6E 69 6E 67 73 - 3B 0A 0A 70 72 69 6E 74 warnings;..print00000030 20 22 48 65 6C 6C 6F 2C - 20 77 6F 72 6C 64 5C 6E "Hello, world\n00000040 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).
Functional Interface
This module exports a single function, "HexDump", which takes a scalar value and returns a string which contains the hexdump of the passed data.
OO Interface
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 contentsprint 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.
Releases
5 releases since Debian 10 (Buster); the text changed 3 times.