in reply to Automatic generation of textfiles
I suggest you take a look at perldoc -f open and your questions should be answered.