#!/usr/bin/perl -w use strict; my $buf; open (IN, "test.txt") || die "can't open test.txt"; binmode (IN); my $actual = read (IN, $buf, 2048); foreach my $i (0..$actual-1) { printf "%02X ", ord(substr($buf,$i,1)); }