Трубы имеют ограниченные размеры. Ваш подход заблокирует
Parent Child
------ -----
... ...
Wait for data in Writer
Put data in Writer
Read data from Writer
Put data in Reader
Wait for data in Writer
Put data in Writer
Read data from Writer
Put data in Reader
=> Blocks cause Reader is full
Put data in Writer
Put data in Writer
...
Put data in Writer
Put data in Writer
=> Blocks cause Writer is full
Одно из возможных решений:
use strict;
use warnings;
use threads;
use IPC::Open2 qw( open2 );
my @cmd = ("addr2line", "-e", $prog_name);
local (*Reader, *Writer);
my $pid = open2(\*Reader, \*Writer, @cmd);
my $thread = async {
for (;;) {
$function_name = <Reader>;
last if !defined($function_name);
$filesource = <Reader>;
#... store ..
}
close Reader;
};
{
my @requests = ...;
for(@requests) { # this array is HUGE, 100s of thousands of entries
print Writer "$_\n";
}
close Writer;
}
$thread->join();
waitpid($pid, 0);
В качестве альтернативы, IPC :: Run имеет инструменты, которые упростят эту задачу.
Единственный способ - использовать IO :: Select , но это настоящая боль.