in reply to Append to file or create file depending on input filename.

Rather than relying on your OS, try Perl's native open:

From perldoc -f open:

open FILEHANDLE,MODE,EXPR,LIST

and, from paragraph 5:

.... If MODE is '>', the file is truncated and opened for output, being created if necessary. If MODE is '>>', the file is opened for appending, again being created if necessary.

Clarification of para 1