How can I set file permissions from Perl?

前端 未结 2 1310
挽巷
挽巷 2021-01-17 09:57

I\'m writing a Perl script that generates a Bash script. I\'m using open() with a mode of > to output everything to a new file. Standard stuff:<

相关标签:
2条回答
  • 2021-01-17 10:11

    You will want to chmod the file like this.

    chmod 0755, $filename;
    #or
    chmod 0755, $fh;
    

    Alternatively, if you use sysopen and set the umask appropriately, you can do without chmod.

    0 讨论(0)
  • 2021-01-17 10:12

    Putting + infront of < or > allows you to open the file in both read and write mode.

    In you case you can chmod the newly created file.

    0 讨论(0)
提交回复
热议问题