#!/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; #### ben@Jotunheim:/tmp$ ./pbvi unix.txt 4C 69 6E 65 20 6F 6E 65 0A 4C 69 6E 65 20 74 77 6F 0A 4C 69 Line one.Line two.Li 6E 65 20 74 68 72 65 65 0A 4C 69 6E 65 20 66 6F 75 72 0A ne three.Line four. #### ben@Jotunheim:/tmp$ ./pbvi windows.txt 4C 69 6E 65 20 6F 6E 65 0D 0A 4C 69 6E 65 20 74 77 6F 0D 0A Line one..Line two.. 4C 69 6E 65 20 74 68 72 65 65 0D 0A 4C 69 6E 65 20 66 6F 75 Line three..Line fou 72 0D 0A r..