use FileHandle; our $LOGFH; #can't figure out a way around using a global var here if ( $opt_s ) { $LOGFH = new_from_fd FileHandle fileno(STDOUT), 'a'; } else { $opt_l ||= $DEFAULT_LOG_FILE; $LOGFH = new FileHandle $opt_l, 'a'; } ( ! defined $LOGFH ) and croak 'Could not open logfile, aborting.'; autoflush $LOGFH 1; #autoflush on $LOGFH->print(scalar localtime, ": running MyProgram.\n") or carp 'Could not print to log.';