In the OPs case, given he only wants a yay or nay answer ... parsing the entire file is a waste of cpu cycles, time, and effort.
You probably have much more experience with working with big data than I do, but in this case: On my machine, on a single 1.6GB video file where there is no match, your code takes 1.6s to complete (when working from disk cache), whereas a patched MP4::Info comes up with an answer in less than 0.1s. And MP4::Info scans 41GB of video files in under a second. Example code:
use MP4::Info 'get_mp4tag'; my $tag = get_mp4tag($ARGV[0]); print $tag && $tag->{HDVD} && $tag->{HDVD}==2 ? "Match! $ARGV[0]\n" : "No Match!\n";
In the general case, I tend to think the right tool for the job is much more likely to be a module (if it exists) - except maybe in the case of large amounts of input data, where optimizations may be necessary.
P.S. I'm sure you've read You can't parse (X)HTML with regex :-)
In reply to Re^5: Search hex string in vary large binary file
by Anonymous Monk
in thread Search hex string in vary large binary file
by westrock2000
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |