Right now, I have a Kornshell script to do this, but I believe it will be faster and more efficient if I rewrite it in Perl.

One of the lines in my shell script does this:

$ cvs rlog -r$OLD::$NEW -SN $module 2> errors.txt > output.txt
I parse "output.txt" to find all the release notes and files that have been changed. In fact, one of the reasons I want to redo this in Perl is that I believe I can do this part of the job more efficiently in Perl. No real problem here. Very basic programming stuff.

The problem is with the "errors.txt" file. I take this file, and do quite a bit of parsing:

First I grep out all the lines that say "warning: no revision `$OLD' in" in one file. I then grep out all the lines that say "warning: no revision `$NEW' in" another file. After that, I do a unified diff on the two outputs. Lines that start with a "-" are for files that have been added since release $OLD. Lines that start with a "+" are for files that have been deleted since release $OLD.

It takes quite a bit of processing. First, I have to capture STDERR in a file, grep it twice, diff it, parse the output and separate out the file name from the rest of the resulting lines.

It should be much, much easier in Perl. I could do everything in a single pass and avoid all temporary files.

However, that's the problem. I can do an "open" on the CVS command to capture STDOUT as if it was a simple text file. But, how in the world do I process the STDERR from that CVS command at the same time? I could (like I do in Kornshell) save the output in a file, and open that file later, but it strikes me there has to be a way I can operate on both STDOUT and STDERR at the same time.


In reply to Parsing STDERR and STDOUT at the same time by qazwart

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.