#!/usr/bin/perl # https://perlmonks.org/?node_id=1230099 use strict; use warnings; open my $x, '<', \do { local $/; }; my $who = fork() ? 'p' : 'c'; while( <$x> ) { print "$who $_"; } 1 while wait > 0; __DATA__ a b c d e