title: Perl: redirect output both to file and console, keeping return code
body: <p>I've a problem. In my Perl script I execute a java program which print both to stdout and stderr streams. Could you please give me a peace of advice of how I can redirect stderr to file only and stdout to the same file and to the console. tee is not applicable here because I also need a return code of the java program. Any ideas?</p>
  
  <p>Thanks in advance!</p>