in reply to How to read from shell command and terminate it afterwards?

Assuming you will always get the line you want:

my $pid = open(my $pipe, 'mDNS -L "Service Name" _service._tcp domain +|'); my $data; while (<$pipe>) { if (/...is desired line.../) { $data = $_; last; } } kill KILL => $pid; print($data);