open my $fh, '<', 'test.elf' or die "can't do anything: $!"; binmode $fh; read $fh, my $stuff, 1000 or die "read error: $!"; close $fh; print length $stuff, " bytes in\n"; my $offs = 0; my @tmp = map $_->[1], grep $_->[0] eq '7f', map [$_, $offs++], unpack "(H2)*", $stuff; # prints "7f" offsets in binary file print join':', @tmp;