#!/usr/bin/perl -w use strict; die "Usage: ", $0 =~ /([^\/]+)$/, " \n" unless @ARGV; open my $fh, $ARGV[0] or die "$ARGV[0]: $!\n"; binmode $fh; my ($hex, $char, $count); { my $res = sysread $fh, my $s, 1; if ($res){ $hex .= sprintf("%02X ", ord($s)); $char .= $s =~ /[[:print:]]/ ? $s : '.'; } if ((++$count % 20 == 0) || !$res){ printf "%-60s%4s%-20s\n", $hex, ' ', $char; $hex = $char = undef; } redo if $res; } close $fh;