in reply to Re^4: Search hex string in vary large binary file
in thread Search hex string in vary large binary file
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 :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Search hex string in vary large binary file
by BrowserUk (Patriarch) on Feb 07, 2015 at 20:55 UTC | |
by Anonymous Monk on Feb 07, 2015 at 21:24 UTC | |
by BrowserUk (Patriarch) on Feb 08, 2015 at 05:08 UTC | |
by Anonymous Monk on Feb 08, 2015 at 11:35 UTC |