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);