in reply to Search in the .tgz file without unpack and untar

If I have a bunch of tar.gz files, and I know these all contain just log file data, and I just want to find and list particular lines that match a given regex pattern -- that is, I don't care which log file(s) are involved, I just want the matching lines -- I would either use a shell command like this:
gunzip -c *.tgz | grep target_regex > target.hits
(You might need an extra option, "--binary-files=text" on the grep command, depending on which version of grep you have.)

Or else I'd write a perl script like this:

#!/usr/bin/perl use strict; use PerlIO:gzip; for my $file (<*.tgz>) { open( T, "<:gzip", $file ) or do { warn "open failed on $file: $!\n"; next; }; while (<T>) { print if /target_regex/; } }
(And in the latter case, I'd probably use @ARGV to set the path for where to find the tgz files, what regex to apply, and/or whether to read the list of tgz file names from STDIN, so that the script serves a general range of uses.)