Data::Hexify(3)

๐Ÿ“ฆ
version 1.00 ยท 2 versions
, in fedora 43

๐Ÿ’– Data::Hexify โ€” the manual page, but make it cute ๐Ÿ’–

okay bestie, gather round, because we're talking about Data::Hexify, a lil Perl module from the User Contributed Perl Documentation corner of the man-verse. It's giving "hexdump but make it a subroutine," and honestly? iconic. โœจ


๐ŸŒธ NAME ๐ŸŒธ

Data::Hexify โ€” a Perl extension for hexdumping arbitrary data. yes, arbitrary. binary chaos welcome. ๐Ÿฆ‹


โœจ SYNOPSIS โœจ

the whole vibe in three lines:

use Data::Hexify;
print STDERR Hexify(\$blob);

that's it. that's the whole thing. slay. ๐Ÿ’…


๐ŸŽ€ DESCRIPTION ๐ŸŽ€

so this module exports exactly one subroutine, and its name is Hexify. one job, does it well, main character energy only. ๐Ÿ‘‘

Hexify takes arbitrary data (possibly binary, possibly cursed, possibly both) and formats it into something suitable for hex dumps, in the style of xd or hexl. no cap.

the first, or only, argument to Hexify is the data you wanna hexify โ€” or a reference to that data. and Hexify hands you back a string that prints like this:

0000: 70 61 63 6b 61 67 65 20 44 61 74 61 3a 3a 48 65  package Data::He
0010: 78 69 66 79 3b 0a 0a 75 73 65 20 35 2e 30 30 36  xify;..use 5.006

and so on, forever, the way that it just keeps going. ๐ŸŒ€

breaking down the anatomy of each line, because i know you wanna know:

  • on the left โ€” the hexadecimal index of the data ๐Ÿ”ข
  • then โ€” a bunch of hex bytes
  • then โ€” the actual chunk of data, except all the unprintables got swapped out for periods ๐Ÿ’€

๐Ÿซถ the optional second argument ๐Ÿซถ

the optional second argument to Hexify must be a hash or a hash reference, and it holds values for any of these parameters. this is the customization menu, bestie, order whatever you want:

  • first โ€” the first byte of the data to be processed. default is to start from the beginning of the data. ๐ŸŒฑ
  • length โ€” the number of bytes to be processed. default is to proceed all data. yes, all of it. greedy behavior, love that for us. ๐Ÿ˜Œ
  • chunk โ€” the number of bytes processed per line of output. default is 16. ๐Ÿ“
  • group โ€” the number of bytes grouped together. default is 1 (which means no grouping, just vibes). if you do use it, heads up: it must be a divisor of the chunk size. math said so, not me. ๐Ÿงฎ
  • duplicates โ€” when set, duplicate lines of output get suppressed and replaced by a single line that reads **SAME**. duplicate suppression is enabled by default. ๐Ÿ™ˆ
  • showdata โ€” a reference to a subroutine used to produce a printable string from a chunk of data. by default, the subroutine used replaces unwanted bytes with periods.

the subroutine gets the chunk of data passed as its argument, and it should return a printable string of at most chunksize characters. ๐ŸŽจ

  • align โ€” align the result to chunksize bytes. this only matters when you're processing data that does not start at the beginning. for example, when first is 10, the result would become:
 0000:                ...    74 61 3a 3a 48 65            ta::He
 0010: 78 69 66 79 3b ... 65 20 35 2e 30 30 36  xify;..use 5.006
 ... and so on ...

alignment is on by default. without alignment, the result would be:

 000a: 74 61 3a 3a 48 ... 79 3b 0a 0a 75 73 65  ta::Hexify;..use
 001a: 20 35 2e 30 30 ... 73 65 20 73 74 72 69   5.006;.use stri
 ... and so on ...

๐Ÿฆ‹

  • start โ€” pretend that the data started at this byte (while in reality it starts at byte first). the example above, with start => 0, becomes:
 0000: 74 61 3a 3a 48 ... 79 3b 0a 0a 75 73 65  ta::Hexify;..use
 0010: 20 35 2e 30 30 ... 73 65 20 73 74 72 69   5.006;.use stri
 ... and so on ...

๐ŸŒˆ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

  • Data::Dumper
  • YAML

go read those too, bestie, knowledge is free and it's giving scholar. ๐Ÿ“šโœจ


๐ŸŒŸ AUTHOR ๐ŸŒŸ

Johan Vromans, <jvromans@squirrel.nl> โ€” absolute legend, we stan. ๐Ÿซถ


Copyright (C) 2004 Squirrel Consultancy

this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.0 or, at your option, any other version of Perl 5 you may have available. so generous, so giving. ๐Ÿ‘‘


ok that's the whole page, no details left behind, every flag accounted for, periodt. ๐Ÿ’…

and that's a wrap on Data::Hexify, documented under perl v5.42.0, dated 2025-07-25. tysm for reading, mwah, go hexdump something cursed. ๐Ÿ’–๐ŸŽ€โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from