There are relevant IPC examples in the Perl Cookbook. The approach that comes to mind for me is to simply have a file that contains the next line to process, and use file-locking to coordinate updates to that file between the two processes. You should read in chunks, not single lines, since single lines are processed so quickly that the lock file would become a bottleneck.