perl -ple "BEGIN{open $to,'>',shift @ARGV and select $to if $ARGV[0]}" # to STDOUT perl -ple "BEGIN{open $to,'>',shift @ARGV and select $to if $ARGV[0]}" 0 src1 src2 # to file perl -ple "BEGIN{open $to,'>',shift @ARGV and select $to if $ARGV[0]}" dst src1 src2