in reply to Permission denied writing to Windows 10

What is your current directory? Most likely, you are simply not allowed to write to whatever directory is your current directory.

You can find the current directory with the following Perl code:

use Cwd; print "Current directory is: ", getcwd; open FILE, ...

Replies are listed 'Best First'.
Re^2: Permission denied writing to Windows 10
by Anonymous Monk on Sep 14, 2016 at 17:18 UTC

    My current directory is the same directory that my perl script lives in. I am running as administrator and as far as I can tell the directory allows Full Control to admins. How can I confirm your suspicion?

      What is the full path? WinDoze got picky about writing to "\Program Files\whatever...." some time ago. Running as Admin doesn't always override that.

      Writing to C:\Public, on the other hand, is unlikely to give you problems, but whatever the issue may be, you'll be well served to create a new directory, on another (local) drive if that's available in which to put your new work. Commingling your Perl install with homework, experiments, learning-challenges and other scripts will be a hassle a few weeks or months from now.

      Just BTW, as this has already been partially addressed by way of correction, but I don't know how the open shown in your OP could work, period, given the missing close-quote, comma operator, space, open-quote sequence. Of course, sometimes I miss the memo... and I did not test your version because I expected a syntax error.

      Update: Please don't read the preceding paragraph. Pretty Please? See Rev. Canon AnomalousMonk's reply below. Watch ww flush with embarrasment! Mea Culpa.

            open FILE,"> hello.txt" or die $!;

        ... I don't know how the open shown in your OP could work, period, given the missing close-quote, comma operator, space, open-quote sequence.

        That's the old, disparaged, denigrated, frowned-upon, but not deprecated two-argument form of open. The file-access specifier is fused with the file name in a single string. IIRC, the space between the  '>' write-access specifier and the file name is just the sort of gateway (among others) to a potential pitfall that the three-argument open was designed to avoid. Yes, it works.


        Give a man a fish:  <%-{-{-{-<

        Thanks for the advice. I am indeed going to just move my stuff to a different directory that seems to work.

        As for the code in the OP, it actually does work. One of the good (and bad) things about Perl is that it is so forgiving of lazy coding. Consider me properly admonished!

      What happens if you type echo . > hello.txt at that same command line?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.

        It works as expected - I get a hello.txt file created with the . in it.