in reply to Redirecting STDOUT to file and screen as an afterthought, on Windows.

To log to file without modifing all your existing prints use select to make print automatically go to a filehandle.

use FileHandle; my $log = 0; print "Do you want to log to a file?"; my $resp = <STDIN>; if ($resp =~ /^y/i) { my $fh = new FileHandle; my $filepath = "c:\\stdout.txt"; $fh->open(">> $filepath") || die "could not open log file $filepat +h"; select $fh; } # # this will go to log file if $resp was y # print "Holla!\n";
-HTH