HDR USER MANUAL

This document will help you understand how to use the hdr command part of the Data::HexDump::Range module. The latest version is at http://search.cpan.org/search?query=Data%3A%3AHexDump%3A%3ARange.

It is important to understand that hdr is a visualisation tool. It does not understand your data.

The hdr command

When in the hexdump land, do as hexdumper do

>$ hdr file_name

00000000 63 6f 6d 6d 69 74 20 38 38 30 39 63 38 65 38 34  commit 8809c8e84 
00000010 65 62 33 32 33 62 62 61 61 33 36 36 39 65 39 34  eb323bbaa3669e94 
00000020 38 62 36 38 35 30 32 36 63 33 35 66 61 35 39 20  8b685026c35fa59  
00000030 28 48 45 41 44 2c 20 6d 61 73 74 65 72 29 0a 41  (HEAD, master).A 
00000040 75 74 68 6f 72 3a 20 6e 61 64 69 6d 20 6b 68 65  uthor: nadim khe 
00000050 6d 69 72 20 3c 6e 6b 68 40 63 70 61 6e 2e 6f 72  mir  
00000060 67 3e 0a 44 61 74 65 3a 20 20 20 53 75 6e 20 41  g>.Date:   Sun A 
00000070 70 72 20 31 38 20 30 33 3a 33 32 3a 30 33 20 32  pr 18 03:32:03 2 
00000080 30 31 30 20 2b 30 32 30 30 0a 0a 20 20 20 20 41  010 +0200..    A 

output format

The data displayed is the same in all the formats hdr supports. The default output format is ANSI. ASCII is like ANSI without the colors.

ASCII

00000000 63 6f 6d 6d 69 74 20 38 38 30 39 63 38 65 38 34  commit 8809c8e84
00000010 65 62 33 32 33 62 62 61 61 33 36 36 39 65 39 34  eb323bbaa3669e94
00000020 38 62 36 38 35 30 32 36 63 33 35 66 61 35 39 20  8b685026c35fa59
00000030 28 48 45 41 44 2c 20 6d 61 73 74 65 72 29 0a 41  (HEAD, master).A
00000040 75 74 68 6f 72 3a 20 6e 61 64 69 6d 20 6b 68 65  uthor: nadim khe
00000050 6d 69 72 20 3c 6e 6b 68 40 63 70 61 6e 2e 6f 72  mir <nkh@cpan.or
00000060 67 3e 0a 44 61 74 65 3a 20 20 20 53 75 6e 20 41  g>.Date:   Sun A
00000070 70 72 20 31 38 20 30 33                          pr 18 03

ANSI

ANSI can't be rendered from pod but it look like the <HTML> below

HTML


00000000 63 6f 6d 6d 69 74 20 38 38 30 39 63 38 65 38 34  commit 8809c8e84 
00000010 65 62 33 32 33 62 62 61 61 33 36 36 39 65 39 34  eb323bbaa3669e94 
00000020 38 62 36 38 35 30 32 36 63 33 35 66 61 35 39 20  8b685026c35fa59  
00000030 28 48 45 41 44 2c 20 6d 61 73 74 65 72 29 0a 41  (HEAD, master).A 
00000040 75 74 68 6f 72 3a 20 6e 61 64 69 6d 20 6b 68 65  uthor: nadim khe 
00000050 6d 69 72 20 3c 6e 6b 68 40 63 70 61 6e 2e 6f 72  mir  
00000060 67 3e 0a 44 61 74 65 3a 20 20 20 53 75 6e 20 41  g>.Date:   Sun A 
00000070 70 72 20 31 38 20 30 33                          pr 18 03         

Showing the column header and the rulers

Command: hdr -col -rul your_file


OFFSET   HEX_DUMP                                         ASCII_DUMP        
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789012345  
00000000 63 6f 6d 6d 69 74 20 38 38 30 39 63 38 65 38 34  commit 8809c8e84 
00000010 65 62 33 32 33 62 62 61 61 33 36 36 39 65 39 34  eb323bbaa3669e94 
00000020 38 62 36 38 35 30 32 36 63 33 35 66 61 35 39 20  8b685026c35fa59  

intput

from file or stdin

too little data

too much data

--max_size

head -c

Displaying selected chunks

range descritption

from command line

from file

simple

advance

use strict ;
use warnings ;
 
my $data_range = # definition to re-use
	[
	  ['data header', 5, 'blue on_cyan'],
	  ['data', 20, 'blue on_bright_yellow'],
	] ;

my $structured_range = 
	[
	    ['zero size', 0],
	  [
	    ['magic cookie', 12, 'red'],
	    ['padding', 32, 'yellow'],
	    $data_range, 
	  ],
             ['other zero size', 0],		
	  [
	    ['extra data', 18, undef],
	      [
	      $data_range, 
	      ['footer', 4, 'bright_yellow on_red'],
 	    ]
  	  ],
 	] ; 
	
$structured_range ;

See "Advanced usage"

Bitfields

command: hdr --col -display_ruler -r 'data,1 :DATA,4:c,b9:d,b3 :e,x4b5 :the end,8:x,b3:data,47:v,x90b8' lib/Data/HexDump/Range.pm -format HTML > file.html

Vertical mode


RANGE_NAME       OFFSET   CUMULATI HEX_DUMP                                         ASCII_DUMP        
                                   0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789012345  
data             00000000 00000000 0a                                               .                
DATA             00000001 00000000 70 61 63 6b                                      pack             
.c               00 .. 08          -- -- 00 e0    011100000-----------------------  .bitfield: --.à  
.d               00 .. 02          -- -- -- 03    011-----------------------------  .bitfield: ---.  
.e               04 .. 08          -- -- -- 00    ----00000-----------------------  .bitfield: ---.  
the end          00000005 00000000 61 67 65 20 44 61 74 61                          age Data         
.x               00 .. 02          -- -- -- 03    011-----------------------------  .bitfield: ---.  
data             0000000d 00000000 3a 3a 48 65 78 44 75 6d 70 3a 3a 52 61 6e 67 65  ::HexDump::Range 
data             0000001d 00000010 20 3b 0a 0a 75 73 65 20 73 74 72 69 63 74 3b 0a   ;..use strict;. 
data             0000002d 00000020 75 73 65 20 77 61 72 6e 69 6e 67 73 20 3b 0a     use warnings ;.  
.v               90 .. 97          -- -- -- 49    ------------------------01001001  .bitfield: ---I  

Horizontal mode


OFFSET   BITFIELD HEX_DUMP                                         ASCII_DUMP       RANGE_NAME                   
                  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789012345                              
00000000          0a 70 61 63 6b 61 67 65 20 44 61 74 61 3a 3a 48  .package Data::H data, DATA, the end, data,  
00 .. 08 DATA     -- -- 00 e0    011100000-----------------------  .bitfield: --.à  .c               
00 .. 02 DATA     -- -- -- 03    011-----------------------------  .bitfield: ---.  .d               
04 .. 08 DATA     -- -- -- 00    ----00000-----------------------  .bitfield: ---.  .e               
00 .. 02 the end  -- -- -- 03    011-----------------------------  .bitfield: ---.  .x               
00000010          65 78 44 75 6d 70 3a 3a 52 61 6e 67 65 20 3b 0a  exDump::Range ;. data,  
00000020          0a 75 73 65 20 73 74 72 69 63 74 3b 0a 75 73 65  .use strict;.use data,  
00000030          20 77 61 72 6e 69 6e 67 73 20 3b 0a               warnings ;.     data,  
90 .. 97 data     -- -- -- 49    ------------------------01001001  .bitfield: ---I  .v               

Bitfields need enough data!

No data to start with


OFFSET   BITFIELD HEX_DUMP                                         ASCII_DUMP       RANGE_NAME                   
                  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789012345                              
00000000          0a 70 61 63 6b 61 67 65 20 44 61 74 61 3a 3a 48  .package Data::H data, DATA, the end, data,  
00 .. 03 ?        ?                                                ?                .a               
00 .. 02 ?        ?                                                ?                .b               
00 .. 00 ?        ?                                                ?                .x               
00 .. 00 ?        ?                                                ?                .y               
00 .. 00 ?        ?                                                ?                .z               
00 .. 08 DATA     -- -- 00 e0    011100000-----------------------  .bitfield: --.à  .c               
00 .. 02 DATA     -- -- -- 03    011-----------------------------  .bitfield: ---.  .d               
04 .. 08 DATA     -- -- -- 00    ----00000-----------------------  .bitfield: ---.  .e               
00 .. 02 the end  -- -- -- 03    011-----------------------------  .bitfield: ---.  .x               
00000010          65 78 44 75 6d 70 3a 3a 52 61 6e 67 65 20 3b 0a  exDump::Range ;. data,  
00000020          0a 75 73 65 20 73 74 72 69 63 74 3b 0a 75 73 65  .use strict;.use data,  
00000030          20 77 61 72 6e 69 6e 67 73 20 3b 0a               warnings ;.     data,  
90 .. 97 data     -- -- -- 49    ------------------------01001001  .bitfield: ---I  .v               

not enough data


OFFSET   BITFIELD HEX_DUMP                                         ASCII_DUMP       RANGE_NAME                   
                  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789012345                              
00000000          0a 70 61 63 6b 61 67 65 20 44 61 74 61 3a 3a 48  .package Data::H data, DATA, the end, data,  
00 .. 48 DATA     ?                                                ?                .c               
49 .. 51 DATA     ?                                                ?                .d               
04 .. 08 DATA     -- -- -- 00    ----00000-----------------------  .bitfield: ---.  .e               
00 .. 02 the end  -- -- -- 03    011-----------------------------  .bitfield: ---.  .x               
00000010          65 78 44 75 6d 70 3a 3a 52 61 6e 67 65 20 3b 0a  exDump::Range ;. data,  
00000020          0a 75 73 65 20 73 74 72 69 63 74 3b 0a 75 73 65  .use strict;.use data,  
00000030          20 77 61 72 6e 69 6e 67 73 20 3b 0a               warnings ;.     data,  
90 .. 97 data     -- -- -- 49    ------------------------01001001  .bitfield: ---I  .v               

Advanced usage

verify your data

display data errors with hdr

gathering data

dynamic range generation

Bash completion script

hdr can generate a bash completion script

$> hdr --generate_bash_completion option > hdr_completion
$> source hdr_completion

Helping out

You can contribute by:

  • report error! "RT ..."

  • send some examples of your data/output

  • send parsers or other scripts that you use hdr in

  • send new requirement, patches, documentation enhancements

  • pass the word around so more people use hdr and I get more feedback

  • plant a tree, save a cat/dog, bike instead for driving, spread some love around you :)

AUTHOR

Nadim ibn hamouda el Khemir
CPAN ID: NKH
mailto: nadim@cpan.org

COPYRIGHT & LICENSE

Copyright 2010 Nadim Khemir.

This program is free software; you can redistribute it and/or modify it under the terms of either:

  • the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or

  • the Artistic License version 2.0.

SUPPORT

You can also look for information at:

  • RT: CPAN's request tracker

    Please report any bugs or feature requests to L <bug-data-hexdump-range@rt.cpan.org>.

SEE ALSO

hexd from libma http://www.ioplex.com/~miallen/libmba/

1 POD Error

The following errors were encountered while parsing the POD:

Around line 157:

Non-ASCII character seen before =encoding in '--.à'. Assuming CP1252