use IO::Handle; # up top ... open STDOUT, '>&', $WRITE or die "failed redirect to STDOUT: $!"; STDOUT->autoflush(1); ...