in reply to Out of Memory

I think that what's happening to you is that your command is missing -e EXPR. Without EXPR, the command will start to run and forget to finish, slowing things down until the whole computer grinds to a halt.

The trick to zgrep is that it really isn't very portable. For example, the -d option isn't supported by my system's grep. Here's what I used that worked:

#!/usr/bin/perl use strict; use warnings; my $file = shift @ARGV; open(INFILE, "|-", "zgrep -c -e / $file ") or die $!; close INFILE;
You'll notice that I used "|-": it writes to STDOUT, which is what I think that you were trying to do. I also tried it with "-|": it writes to STDIN, and that didn't work.

Replies are listed 'Best First'.
Re^2: Out of Memory
by NetWallah (Canon) on Jun 04, 2011 at 19:34 UTC
    Your example sends zgrep's output directly to STDOUT, avoiding the need to read it using "while (<INFILE>)".

    I think the OP's intent is to read and process the output of zrep, so, he should use "-|", and read it using "while(<INFILE>)".

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