Subject: | Nested capture_merged and system calls |
This script
#!/usr/bin/perl
use Capture::Tiny qw(capture_merged);
use warnings;
use strict;
my ( $outer, $inner );
$outer = capture_merged {
$inner = capture_merged {
print STDERR q{message1};
system("perl -e 'print STDERR q{message2}'");
};
};
printf "outer = '%s'\n", $outer || 'undef';
printf "inner = '%s'\n", $inner || 'undef';
prints
outer = 'message2'
inner = 'message1'
so the standard error of the system() command goes to the outer capture,
rather than the inner one. This is obviously confusing if the inner and
outer captures are separated by many scopes.
Is this a bug or just an unavoidable side-effect of the way
capture_merged is implemented?
Reproduced on both OS X perl5.12 and Debian perl5.14.