################## # Server: open my $msgs, "| tail -f data.txt" or die "ouch: $!"; while (<$msgs>) { # do something with this line of data } ################## # Client: use Fcntl ':flock'; while () { chomp; open my $msgs, '>>', 'data.txt' or die "ouch: $!"; flock $msgs, LOCK_EX; print( $msgs, ($_ . "\n") ); close $msgs; }