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
Nevermind. Figured it out. Throwing in an ampersand does the trick. Full working code is: open( OUTPUT, ( $output ? ">$output" : ">&STDOUT" ) );
open( OUTPUT, ( $output ? ">$output" : ">&STDOUT" ) );