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 |
|