in reply to Pattern matching in binary mode

In addition to the above with a binary file you have a stream of bytes. Some of those will be what we refer to as newline chars (10 0xA \012) if we had a text file so if you do:

open F, $file or die $!; binmode F; while (<F>) { # $_ will contain a randomish length of string # which simply depends on where the newline chars fall }

If you don't want to find a pattern like \032\012\032 which would appear in two different reads from <F> then you have no issue. Typically you read binary files using read and ask for X number of bytes to be read, but for your purposes <F> should probably be fine. If you do need to match strings that contain \012 then you will need to read and buffer. This is more complex.

Don't forget to binmode your output handle as well.

cheers

tachyon