in reply to check if file is executable by user/group/world?

so how would I, then, turn said bit off and on? I assumed it would be something like this, but it clearly does not work:
use Fcntl ':mode'; $file = 'myfile'; $mode = (stat($file))[2]; chmod ($mode | S_IXOTH), $file;

Replies are listed 'Best First'.
Re^2: check if file is executable by user/group/world?
by XooR (Beadle) on Aug 06, 2009 at 18:01 UTC

    This is why you should use warnings and strict in your code. With warnings turned on you should get next warning:

    Useless use of array element in void context at ./file_change_mode.pl line 12.

    Reason why this is happening you can see in perlfunc.

    You could write:
    chmod(($mode | S_IXOTH), $ARGV[0]);