in reply to Does print() write immediately to a file?

It gets buffered. You can enable autoflushing to force it to go the file sooner.

Run perldoc -q flush or read this: How do I flush/unbuffer an output filehandle? Why must I do this?.