in reply to File::Path problem (will not create file if directory with same name exists)

By opening a file in the "read" mode ('<'), you aren't creating anything. Show us the code that worked for you, because as far as I know, it's not possible to have a file and a directory of the same name in the same location.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re: File::Path problem (will not create file if directory with same name exists)
  • Download Code

Replies are listed 'Best First'.
Re^2: File::Path problem (will not create file if directory with same name exists)
by james28909 (Deacon) on May 18, 2014 at 21:57 UTC
    apologies, i am actually using '>'. updated original question
      The second part of my reply still holds. It's not possible. If it were possible and you told your system to open path/example, which one should it open?
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^2: File::Path problem (will not create file if directory with same name exists)
by james28909 (Deacon) on May 18, 2014 at 21:59 UTC
    oh i did not even know you couldnt create a file and directory of the same name in the same directory. seems i have to make a temp folder and then copy the file to the right location. thanks for pointing that out. real noob moment lol

      Hint: Create a file with a temporary filename in the correct location, write the file's content and attributes and if everything went well rename it into the correct filename. If something fails delete the file.

      Of course you can create the tempfile somewhere else, but then the copy operation may fail (not enough diskspace? insufficent permissions?) which could leave you with an incomplete/invalid file. Reducing the 'critical' operation to a rename drastically reduces the chances of something going wrong.

Re^2: File::Path problem (will not create file if directory with same name exists)
by james28909 (Deacon) on May 18, 2014 at 22:02 UTC
    funny thing is i been hung up on this particular problem for about 5 hours now trying to figure out what was wrong with my code lol
      Hello, james28909.

      FWIW cAsE matters. Meaning; if it should help, you could Write Example into the same directory.

      Perhaps obvious. But thought it worth mentioning, just the same. ;)

      --Chris

      ¡λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

        Yes, or the file example.txt or example.dat could be created without any problem.