#!/usr/bin/perl use strict; use warnings; open my $fh, '<', shift or die "Error: $!"; my $chunk; my $find = 'regf'; while (my $bytes = read $fh, $chunk, 1024) { unless ((my $idx = index $chunk, $find) < 0) { printf "Found %s at offset %x\n", $find, tell $fh + $idx - $bytes; } }