in reply to Check if a file exists and if not create it

Surprising. Opening a file in ">>" mode should create the file if it does not exist. And it does. Just opening the file without even doing anything to it (not trying to write anything) creates an empty file:
$ perl -e 'open my $fh, ">>", "bar.txt" or die "can open file $!"; '
is sufficient to create the bar.txt file:
$ ls -l bar* -rw-r--r-- 1 Laurent None 0 20 Aug 23:05 bar.txt