http://www.perlmonks.org?node_id=1196690


in reply to Re^3: Searching large files a block at a time
in thread Searching large files a block at a time

Thanks again, Ken. I've built this code using your and Mario's responses:
$/ = ""; open my $fh, "-|", "/usr/bin/bzcat $file"; while (<$fh>) { if (/uid=$mbnum/m) { print $_; last; } }

I've timed this version, and all others: this completed in 3.2 seconds, the previous version I built with your help took 8 seconds, and my original took 25.4! As I need to scan through three different LDIF's, that's a total of under 10 seconds, on average.