... use constant READ_PERM => 0x04; use constant WRITE_PERM => 0x02; use constant EXECUTE_PERM => 0x01; use constant NO_PERM => 0x00; my $allowed_perms = READ_PERM | WRITE_PERM; # Check for permissions: if ( $allowd_perms == NO_PERM ) { print "PERMISSION DENIED\n" exit -1; } if ( $allowed_perms & READ_PERM ) print "READ Allowed\n"; if ( $allowed_perms & WRITE_PERM ) print "WRITE Allowed"; if ( $allowed_perms & EXECUTE_PERM ) print "EXECUTE Allowd\n"; ... #### use constant READ_PERM => READ_PERM use constant WRITE_PERM => WRITE_PERM; use constant EXECUTE_PERM => EXECUTE_PERM; my @allowed_perms = ( READ_PERM, EXECUTE_PERM ); # Check permissions if ( scalar(@allowed_perms) == 0 ) { print "PERMISSION DENIED\n"; exit -1; } if ( grep { $_ == READ_PERM } @allowed_perms ) print "READ Allowed\n"; if ( grep { $_ == WRITE_PERM } @allowed_perms ) print "WRITE Allowed\n"; if ( grep { $_ == EXECUTE_PERM } @allowed_perms ) print "EXECUTE Allowed\n";