Here is the fact behind what you observed: there are actually two types of buffering mechanism: line buffering and block buffering.
When you print to STDOUT:
- The output is line buffered, if the target is a terminal; (This why you see output every 3 seconds on the screen, if you run your blackbox.pl on its own.)
- otherwise (including pipe) the output is block buffered. (So in the pipe case, the problem is not your monitor program. But your blackbox.pl no longer outputs at the same pace, because of block buffering.)
By setting $| as Anonymous Monk indicated, you force the output to be flushed after each write.