How Do I Point a File Handle to STDOUT (or Another File Handle) In Perl?

前端 未结 5 1868
不知归路
不知归路 2021-01-31 18:19

I want to make a quick script that writes to a file if a file is given, or stdout if no file is given. It would be much easier for me to do this if I could start the script by p

5条回答
  •  滥情空心
    2021-01-31 18:33

    You could always just write the regular output to STDOUT and your debug statements to STDERR. Then if the user wants the output to go to a file they can just redirect STDOUT to the file on the command line.

提交回复
热议问题