in reply to Parsing STDERR and STDOUT at the same time

You can redirect STDERR to STDOUT using the shell.

my $cvs_cmd = "cvs rlog -r$OLD::$NEW -SN $module"; my $cvs_pid = open my $cvs_pipe, '-|', "$cvs_cmd 2>&1" or die "Can't read pipe: $!";

Then read from $cvs_pipe like any other file handle. The STDERR output will be mixed in with the STDOUT output.

I hear IPC::Run is good for this kind of thing, but I've never used it.

Replies are listed 'Best First'.
Re^2: Parsing STDERR and STDOUT at the same time
by qazwart (Scribe) on Feb 02, 2007 at 15:49 UTC
    That's true about blending <STDERR> and <STDOUT> in the CVS command itself, but I don't want to mix up STDERR and STDOUT.

    I process STDOUT for the names of the files and the changes. The flow is pretty straight forward on finding the comments (likes after /^date:/ begin a comment. Comments end with a /^(-|=)+$/. If STDERR was included in the mix, it makes it much harder to separate out that information.

    I also depend upon the fact that when a file isn't tagged with either release, the two lines that report this information appear one after the other in <STDERR>. This makes it very easy to determine when a file has one tag, but not the other (which means it was either added or deleted from the current release). If <STDOUT> and <STDERR> were merged, I could no longer make that assumption.