#!/usr/bin/perl -w use strict; $/ = \16; my $line_no = 0; binmode ARGV; while(<>){ my @hex = map{sprintf "%02x",ord($_) & 0xff} split//; push @hex, (' ') x (16 - @hex); tr/\000-\040\177/./; printf "%05x %s %s\n", $line_no++, "@hex", $_; }