The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
sub _autoflush {
    my $flushed = shift;
    my $old_fh  = select $flushed;
    $| = 1;
    select $old_fh;
}

_autoflush( \*STDOUT );
_autoflush( \*STDERR );

print STDOUT "one\n";
print STDERR "two\n\n";
print STDOUT "three\n";