# print character table; column & row headings are compsed of hex numbers sub hex_table { my @hex = (0..9 , 'a'..'f'); # number of characters each table cell takes my $cell_width = 4; # create row separator; adjust to your liking my $row_sep = "\n--"; $row_sep .= ($_ % $cell_width != 0) ? "-" : "." for 0 .. ( $cell_width * scalar(@hex) ); $row_sep .= "\n"; # space filler heading, common to column & row headings print '0x|'; # column heading printf ' %s |', $_ for @hex; foreach my $row (@hex) { print $row_sep; # row heading printf '%s |', $row; foreach my $col (@hex) { printf ' %c |', hex( $row . $col ); } } } # list characters 8 on each line; each character is preceded by its hex # & decimal number representation sub hex_dec_list { foreach (0..255) { # print hex, decimal numbers followed by character printf ' %1$2x %1$3u: %1$c |' , $_; # allow 8 sets per line print "\n" if $_ && ($_ + 1 ) % 8 == 0; } }