This is no longer a Perl question, but take a look at the tee Unix/Linux command.
Update: oops, looking again at your OP, it seems that you are under Windows, not Unix. There are some Windows tee implementations (e.g. wintee or Powershell Tee) but I just don't know if they fit your requirement.