in reply to how can i open a new file with permission 0666 ?
I think you might have the order of the parameters reversed. perldoc chmod
As for how to open with permission 0666, I can recommend perldoc perlopentut.