I do this all the time, works fine, just be sure to use binmode after you open the file, then slurp the whole file into a string (reading line-by-line makes no sense with a binary file). For example:
use strict; open(my $fh, '<', 'some_binary_file') or die; binmode($fh); my $file_contents = do { local $/; <$fh> }; close($fh); $file_contents =~ /some-string/ and print "it matched\n";
In reply to Re: Reading a binary file
by eyepopslikeamosquito
in thread Reading a binary file
by PrimeLord
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |