in reply to Script with tcpdump freezes

There's nothing there to flush your second print. I bet it reaches the second print, but you just don't see it. Change your prints to print("****************\n"); (note the newline) assuming you're not redirecting STDOUT, or add $| = 1; at the top. That will fix your problem of not seeing the stars, and others have suggested solutions to fix your real problem.