in reply to tcpdump: setting a conditional timeout

Your task is perfect for IPC::Run, try it :)

You can redirect output to a scalar, update (pump) it when you need and timeouts are supported automatically.