That does work, unfortunately my "real" script is waiting for output from a module that is using a foreach loop that could potentially contain thousands of elements, and I need to be able to detect them as soon as they get written.
Maybe writing to a file and reading from the file at the same time isn't the most efficient means of communication between the two scripts. It's possible to write to a logfile, and also open a pipe between two processes. With IO::Tee you could write to both filehandles simultaneously.