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 " >>> ", $_; } }