if (my $pid = open(JSON, '|-') { # database stuff print JSON $json; } else { # this is the child fork. # STDIN here is actually JSON in the other fork. # network stuff my $json = <>; # some more network stuff I guess }