in reply to Wierd Windows Parse::RecDescent output problem

The trace is printed to TRACE, not ERROR, so I don't see how you get the trace structure to be redirected in the first.

But if I redirect TRACE in the same manner as you redirected ERROR it works fine in Active Perl 5.8.8 build 817. I'll see about trying other versions. (By the way, there's also TRACECONTEXT. It probably needs redirecting too.)

use strict; use warnings; use Parse::RecDescent; $::RD_ERRORS=1; $::RD_WARN=1; $::RD_HINT=1; $::RD_TRACE=1; open(Parse::RecDescent::ERROR, '>', 'errfile') or die("Can't redirect errors to file 'errfile': $!\n"); open(Parse::RecDescent::TRACE, '>', 'tracefile') or die("Can't redirect errors to file 'tracefile': $!\n"); Parse::RecDescent->new('parse:')->parse('');
>perl 659805a.pl printing code (3018) to RD_TRACE >type errfile Parse::RecDescent: Treating "parse:" as a rule declaration >type tracefile 1| parse |Trying rule: [parse] | 1| parse |Trying production: [] | 1| parse |>>Matched production: []<< | 1| parse |>>Matched rule<< (return value: | | |[parse]) | 1| parse |(consumed: []) |

In any case, it's not an error with Parse::RecDescent. Taking out the relevant bits:

use strict; use warnings; use vars '$tracemsg'; use vars '$tracecontext'; use vars '$tracerulename'; use vars '$tracelevel'; open (TRACE, ">&STDERR"); format TRACE = @>|@|||||||||@^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<| $tracelevel, $tracerulename, '|', $tracemsg | ~~ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<| $tracemsg . $tracemsg = 'tracemsg'; $tracecontext = 'tracecontext'; $tracerulename = 'tracerulename'; $tracelevel = 'tracelevel'; write TRACE; open(TRACE, ">tracefile") or die; $tracemsg = 'tracemsg'; $tracecontext = 'tracecontext'; $tracerulename = 'tracerulename'; $tracelevel = 'tracelevel'; write TRACE;
>perl -v This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 25 registered patches, see perl -V for more detail) Copyright 1987-2006, Larry Wall Binary build 817 [257965] provided by ActiveState http://www.ActiveSta +te.com Built Mar 20 2006 17:54:25 ... >perl 659805b.pl tr|tracerulen|tracemsg | >type tracefile tr|tracerulen|tracemsg |

Replies are listed 'Best First'.
Re^2: Wierd Windows Parse::RecDescent output problem
by dreadpiratepeter (Priest) on Jan 02, 2008 at 17:04 UTC
    I did a little more digging. apparently it is the format that is not working. if I replace the 'write ERROR;' in the _error routine with a 'printf ERROR ...' the information prints properly.
    So for some reason, formats are not working in my version of Perl.


    -pete
    "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."