1Data::HexDump(3) User Contributed Perl Documentation Data::HexDump(3)
2
3
4
6 Data::HexDump - Hexadecial Dumper
7
9 Functional interface:
10
11 use Data::HexDump;
12 print HexDump($data_string);
13
14 OO interface:
15
16 use Data::HexDump;
17 my $dumper = Data::HexDump->new();
18 print while $_ = $dumper->dump;
19
21 This module will generate a hexadecimal dump of a data string or file.
22 You can either use the exported function, as shown in the SYNOPSIS
23 above, or the OO interface, described below.
24
25 The second example from the SYNOPSIS generated this output:
26
27 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF
28
29 00000000 23 21 2F 75 73 72 2F 62 - 69 6E 2F 70 65 72 6C 0A #!/usr/bin/perl.
30 00000010 75 73 65 20 73 74 72 69 - 63 74 3B 0A 75 73 65 20 use strict;.use
31 00000020 77 61 72 6E 69 6E 67 73 - 3B 0A 0A 70 72 69 6E 74 warnings;..print
32 00000030 20 22 48 65 6C 6C 6F 2C - 20 77 6F 72 6C 64 5C 6E "Hello, world\n
33 00000040 22 3B 0A ";.
34
35 The result is returned in a string. Each line of the result consists
36 of the offset in the source in the leftmost column of each line,
37 followed by one or more columns of data from the source in hexadecimal.
38 The rightmost column of each line shows the printable characters (all
39 others are shown as single dots).
40
41 Functional Interface
42 This module exports a single function, "HexDump", which takes a scalar
43 value and returns a string which contains the hexdump of the passed
44 data.
45
46 OO Interface
47 You first construct a "Data::HexDump" object, then tell it where to get
48 the data from, and then generate the hex dump:
49
50 my $dh = Data::HexDump->new();
51
52 $dh->data($scalar); # dump the data in this scalar
53 $dh->fh($fh); # read this filehandle
54 $dh->file($filename); # read this file and dump contents
55
56 print while $_ = $dh->dump;
57
58 The different potential sources for data are considered in the order
59 given above, so if you pass to the "data" method, then any subsequent
60 calls to fh() or file() will have no effect.
61
63 Data::Hexify, by Johan Vromans, is another simple option, similar to
64 this module. Last release in 2004.
65
66 Data::Hexdumper (by David Cantrell, DCANTRELL) is another hex dumper,
67 with more features than this module.
68
69 App::colourhexdump (by Kent Fredric, RIP) provides a script which gives
70 colourised output with character class highlighting.
71
72 Data::HexDump::Range provides more functions, colour output, and the
73 ability to skip uninteresting parts of the input data.
74
75 Data::HexDump::XXD provides hex dumps like xxd. It doesn't say what
76 xxd is, or provide a link, and there's no example output. But if you
77 know and like xxd, this might be the one for you!
78
79 Devel::Hexdump provides some configuration options, but there are other
80 more featured modules, and this one doesn't have example output in the
81 doc.
82
83 Data::Peek is a collection of functions for displaying data, including
84 "DHexDump" which generates a simple hex dump from a string.
85
86 String::HexConvert will convert ASCII strings to hex and reverse.
87
89 Fabien Tassin <fta@oleane.net>
90
92 Copyright (c) 1998-1999 Fabien Tassin. All rights reserved. This
93 program is free software; you can redistribute it and/or modify it
94 under the same terms as Perl itself.
95
96
97
98perl v5.36.0 2023-01-20 Data::HexDump(3)