use Fcntl qw(:seek);
my($fh, $filename, $byte_position, $byte_value);
$filename = "/some/file/name/goes/here";
$byte_position = 42;
open($fh, "<", $filename)
|| die "can't open $filename: $!";
binmode($fh)
|| die "can't binmode $filename";
sysseek($fh, $byte_position, SEEK_CUR) # NB: 0-based
|| die "couldn't see to byte $byte_position in $filename: $!";
sysread($fh, $byte_value, 1) == 1
|| die "couldn't read byte from $filename: $!";
printf "read byte with ordinal value %#02x at position %d\n",
ord($byte_value), $byte_position;
Run Code Online (Sandbox Code Playgroud)