in reply to what does '$| = 1' mean?
Well, this sets the scalar variable '$|' to 1. $| is a special variable that controls autoflushing of the currently select()ed handle. See perlvar for details.