in reply to File::Binary help

I would do this with perl's builtin functions, not File::Binary.

To search for a string in a binary file, you can use a sliding window, such as

my $s = "YOUR_NEEDLE"; open my $f, "<", "YOUR_FILENAME" or die "open error: $!"; binmode $f o +r die "binmode error: $!"; my($b0, $b1) = ""; my($r, $g) = 0; do { $b1 = $b0; $r = read($f, $b0, 1024); defined($r) or die "read err +or: $!"; $r == 0 and die "string not found"; } until 0 <= ($g = index($b1 . $b0, $s)); my $pos = tell($f) - length($b0) - length($b1) + $g + length($s);

(Update: the easy way is { local $/ = $s; defined(readline $f) or die "error read: $!"; } $pos = tell($f);, but that reads a large chunk of file to memory.)

Then you can seek to $pos, and read the data from there with read. You can interpret binary data with unpack.

Update: corrected error in first sentence, noticed by BrowserUk.