if ( "true" == $flag ) { open ( OUT, "output.txt" ) or die ( "could not open output.txt: $!" ); } else { = ; } print OUT "If $flag is true, this line will go to the file output.txt\nIf $flag is false, it will go to standard output\n";