sub printtolog { my $txt = shift; my $logf; $txt = getdirdatetag() . ': ' . $txt . "\n"; # see https://perldoc.perl.org/functions/open open($logf, ">>:utf8", $logging_logfile) || die "$0: can't open $logging_logfile for appending: $!"; # see https://perldoc.perl.org/functions/select # this does not work # my $oldfh = select $logf; # $| = 1; # select($oldfh); # this also does not work # $logf->autoflush(1); print $logf $txt; # this does not work # $logf->flush; # $logf->sync; # this also does not work # $select()->flush(); # $select()->sync(); close $logf; }