my $exitcode = do { use IO::Tee; open my $ef, '>>', '/path/to/stderr.txt' or die $!; open my $of, '>>', '/path/to/stdout.txt' or die $!; local *STDERR = *{IO::Tee->new('> /dev/tty', $ef)}; local *STDOUT = *{IO::Tee->new('> /dev/tty', $of)}; warn scalar localtime; print scalar(localtime), "\n"; warn 'Here I am!'; print "Here, too!\n"; system '/loc/of/perl', '/path/to/sample1.pl'; };