1Data::Hexify(3) User Contributed Perl Documentation Data::Hexify(3)
2
3
4
6 Data::Hexify - Perl extension for hexdumping arbitrary data
7
9 use Data::Hexify;
10 print STDERR Hexify(\$blob);
11
13 This module exports one subroutine: "Hexify".
14
15 "Hexify" formats arbitrary (possible binary) data into a format
16 suitable for hex dumps in the style of "xd" or "hexl".
17
18 The first, or only, argument to "Hexify" contains the data, or a
19 reference to the data, to be hexified. Hexify will return a string that
20 prints as follows:
21
22 0000: 70 61 63 6b 61 67 65 20 44 61 74 61 3a 3a 48 65 package Data::He
23 0010: 78 69 66 79 3b 0a 0a 75 73 65 20 35 2e 30 30 36 xify;..use 5.006
24
25 and so on. At the left is the (hexadecimal) index of the data, then a
26 number of hex bytes, followed by the chunk of data with unprintables
27 replaced by periods.
28
29 The optional second argument to "Hexify" must be a hash or a hash
30 reference, containing values for any of the following parameters:
31
32 first
33 The first byte of the data to be processed. Default is to start
34 from the beginning of the data.
35
36 length
37 The number of bytes to be processed. Default is to proceed all
38 data.
39
40 chunk
41 The number of bytes to be processed per line of output. Default is
42 16.
43
44 group
45 The number of bytes to be grouped together. Default is 1 (no
46 grouping). If used, it must be a divisor of the chunk size.
47
48 duplicates
49 When set, duplicate lines of output are suppressed and replaced by
50 a single line reading "**SAME**".
51
52 Duplicate suppression is enabled by default.
53
54 showdata
55 A reference to a subroutine that is used to produce a printable
56 string from a chunk of data. By default, a subroutine is used that
57 replaces unwanted bytes by periods.
58
59 The subroutine gets the chunk of data passed as argument, and
60 should return a printable string of at most "chunksize" characters.
61
62 align
63 Align the result to "chunksize" bytes. This is relevant only when
64 processing data not from the beginning. For example, when "first"
65 is 10, the result would become:
66
67 0000: ... 74 61 3a 3a 48 65 ta::He
68 0010: 78 69 66 79 3b ... 65 20 35 2e 30 30 36 xify;..use 5.006
69 ... and so on ...
70
71 Alignment is on by default. Without alignment, the result would be:
72
73 000a: 74 61 3a 3a 48 ... 79 3b 0a 0a 75 73 65 ta::Hexify;..use
74 001a: 20 35 2e 30 30 ... 73 65 20 73 74 72 69 5.006;.use stri
75 ... and so on ...
76
77 start
78 Pretend that the data started at this byte (while in reality it
79 starts at byte "first"). The above example, with "start => 0",
80 becomes:
81
82 0000: 74 61 3a 3a 48 ... 79 3b 0a 0a 75 73 65 ta::Hexify;..use
83 0010: 20 35 2e 30 30 ... 73 65 20 73 74 72 69 5.006;.use stri
84 ... and so on ...
85
87 Data::Dumper, YAML.
88
90 Johan Vromans, <jvromans@squirrel.nl>
91
93 Copyright (C) 2004 Squirrel Consultancy
94
95 This library is free software; you can redistribute it and/or modify it
96 under the same terms as Perl itself, either Perl version 5.6.0 or, at
97 your option, any other version of Perl 5 you may have available.
98
99
100
101perl v5.36.0 2022-07-22 Data::Hexify(3)