#!/usr/bin/perl -w use strict; use warnings; use IO::Handle; STDOUT -> autoflush (1); use Fcntl qw(:DEFAULT :flock); my $log = 'testrw_log.txt'; if (sysopen (my $file,$log,O_WRONLY|O_TRUNC|O_CREAT)) { $file -> autoflush (1); my $z = 0; while (1==1) { $z ++; print $file "Test $z\n"; print STDOUT "Habe Zeile $z geschrieben\n"; sleep 1; } } else { print "Fehler $!\n"; }