in reply to UNIX File Permissions equal or less than conditions

Binary XOR and AND are the answers I would have expected to give, yet you state they don't give the info you need.

Perhaps you can explain that. In the meantime:
Update: SuicideJunkie combines both bit checks in the same mask, much more elegant. Apparently marinersk needs coffee. Or sleep.

#!/usr/bin/perl -w use strict; my $MASK_WRITE_GROUP = 0020; my $MASK_WRITE_WORLD = 0002; my @TestData = ( 0644, 0750, 0751, 0754, 0755, # success tests 0756, 0757, 0752, # failure tests ); { foreach my $permissionsMask (@TestData) { printf "Checking %04o - ", $permissionsMask; my $groupWritePermission = ( $permissionsMask & $MASK_WRITE_GR +OUP ); my $worldWritePermission = ( $permissionsMask & $MASK_WRITE_WO +RLD ); if ( $groupWritePermission || $worldWritePermission ) { print "FAIL\n"; } else { print "PASS\n"; } } } exit; __END__ C:\Steve\Dev\PerlMonks\P-2013-09-17@2251-BitMask>bitmask.pl Checking 0644 - PASS Checking 0750 - PASS Checking 0751 - PASS Checking 0754 - PASS Checking 0755 - PASS Checking 0756 - FAIL Checking 0757 - FAIL Checking 0752 - FAIL

Replies are listed 'Best First'.
Re^2: UNIX File Permissions equal or less than conditions
by marinersk (Priest) on Sep 17, 2013 at 21:17 UTC
    So the changes:

    my $DANGER_BITS = 0022; my $dangerBitCheck = ( $permissionsMask & $DANGER_BITS ); if ($dangerBitCheck) { print "FAIL\n"; }
      All -- thanks for the insight. I ended up with
      if ($mode & 07022) { ... }
      (I also want to check for setuid/setgid/sticky.) I knew that bitwise was the best way to go, thanks for setting me back on the path.