I would like to redirect both stdout and stderr to file1, but also redirect only stderr to file2. Is this possible? I have a working script for part 1, but can't figure out how to additionally write stderr to file2, without overwriting the redirection to file1 (in actuality, the first stderr redirect is going to stdout which then goes to file1). I'm trying to do this so file1 can contain print statements and errors as it would if I were running in a console, and file2 will just log the errors.
Any idea on the best way to achieve this without straying too much from what I already have?
open STDOUT, '>', "$file1" or die $!; # redirect stdout to file
open STDERR, '>&STDOUT' or die $!; # redirect standard error to stdout
# now how to *also* redirect STDERR to $file2?
Thanks
Edit: I do not believe this is a duplicate of this question; it it is, I'm missing it. They wanted to get the output to the screen and into a logfile, I want my stdout/stderr to go to the same file in addition to only stderr going to another file of its own. I don't want (or can't see) any output on the screen. This is like my 3rd time writing in perl so it's pretty new to me. I've been looking at this for hours (including already looking at the 'duplicate' post you linked), and can't find a reasonable solution to my problem.