in reply to How to capture Net::SFTP::Foreign output

You can capture or redirect the STDERR channel at will, just like any filehandle. This should work for operations that are shelled out as well. Details are in open, but a simple bit of code looks like:

#!/usr/bin/perl use warnings; use strict; open my $olderror, ">&STDERR" or die "Can't dup STDERR: $!"; open STDERR, ">&STDOUT" or die "Can't dup STDOUT: $!"; warn "This is sent on STDOUT\n"; open STDERR, ">&", $olderror or die "Can't dup \$olderror: $!"; warn "This is sent on STDERR\n";

Note STDERR, like all bareword filehandles, is global in scope and so you might be messing in someone else's backyard. Note as well you'll probably want to restore the channel, as I have, when you are done with it.