in reply to Out of Memory

Your "open" is probably failing silently, and it is doubtful if your "Out of memory" is in this code.

Perhaps , what you intended was:

open(INFILE, "-|", "zgrep -dc $myfile") or die "Could not zgrep $myfil +e : $!";

            "XML is like violence: if it doesn't solve your problem, use more."