in reply to Vexing Race Condition

Other have already provided you with a solution to your code problems. If you want an alternative to using temporary files for sending the progress of your script to some other program, Net::Clacks might be of help to you Net::Clacks for IPC (2024 tutorial).

Even Santa uses it to monitor his factory: https://perladvent.org/2024/2024-12-13.html

PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Also check out my sisters artwork and my weekly webcomics