qazwart has asked for the wisdom of the Perl Monks concerning the following question:
One of the lines in my shell script does this:
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.$ cvs rlog -r$OLD::$NEW -SN $module 2> errors.txt > output.txt
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing STDERR and STDOUT at the same time
by liverpole (Monsignor) on Feb 01, 2007 at 22:02 UTC | |
by ikegami (Patriarch) on Feb 02, 2007 at 17:05 UTC | |
by liverpole (Monsignor) on Feb 02, 2007 at 19:18 UTC | |
by ikegami (Patriarch) on Feb 02, 2007 at 19:56 UTC | |
by qazwart (Scribe) on Feb 02, 2007 at 15:50 UTC | |
|
Re: Parsing STDERR and STDOUT at the same time
by Tanktalus (Canon) on Feb 01, 2007 at 21:36 UTC | |
|
Re: Parsing STDERR and STDOUT at the same time
by kyle (Abbot) on Feb 01, 2007 at 20:02 UTC | |
by qazwart (Scribe) on Feb 02, 2007 at 15:49 UTC |