in reply to searching for a binary string in a binary file
Since you're looking for the offset of an exact match, the index function is ideal for you. There's no need to use an escaped regex (which could be done with /\Q$letter\E/).
Also, with a binary file, reading with the diamond op is chancy. You don't know where the audio may have a crlf pair. You clearly want to slurp the whole file into $word, so undefine $/ to make diamond do that.
If you need more sophisticated analysis, take a look at PDL.my $word = do { local $/; <WORDSOUND> }; my $offset = index $word, $letter;
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: searching for a binary string in a binary file
by thor (Priest) on Dec 12, 2004 at 06:24 UTC | |
|
Re^2: searching for a binary string in a binary file
by rochlin (Acolyte) on Dec 12, 2004 at 02:18 UTC |