While attractive, this is just one more way of tieing the STDERR glob. Because this nor any of the other tie methods 'really' hook into the filehandle used by STDERR they don't help capture the low-level references to STDERR (aka fileno(STDERR)==2) done by code like Devel::Peek.
Tested with the following code it fails the "warn test" and testing versus Mr. Muskrat's target Devel::Peek:
use IO::Capture::Stderr;
use Devel::Peek;
my $data;
print STDERR " STDERR test (1)\n";
my $capture = IO::Capture::Stderr->new();
$capture->start();
print STDERR " STDERR test (2)\n";
warn " STDERR test (2a)";
my $test = 'string';
Dump($test);
$capture->stop();
print STDERR " STDERR test (3)\n";
my @the_output = $capture->read;
if( @the_output ) {
foreach (@the_output) {
print " >>> ", $_;
}
}
produces output
STDERR test (1)
STDERR test (2a) at mrmskrat4.pl line 15.
SV = PV(0x183ec0c) at 0x197138c
REFCNT = 1
FLAGS = (PADBUSY,PADMY,POK,pPOK)
PV = 0x196deb4 "string"\0
CUR = 6
LEN = 7
STDERR test (3)
>>> STDERR test (2)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|