open my $tailfh, "tail -F $logfile |" or die "blunze: $!\n"; #### my @lines; while (<$tailfh>) { push @lines, $_; unless (-f $lockfile) { open my $chunkfh, '>>', $chunkfile or die "more blunze: $!\n"; $| = 1; # or use IO::File and autoflush print $chunkfh @lines; close $chunkfh; @lines = (); } }