in reply to Unwanted Octal to Decimal Conversion

Update: Okay, I realized I was misreading the sprintf documentation on padding during numeric conversions. How about this:
use constant OTHER_READ => sprintf("%.4o", 0001)
No, why that? If you put soemthing into your db it does not matter if the num is oct hex or dec. The same goes for other operators that you like to use +-|& for example.
# all three lines do exactly the same. chmod 0644, $file; chmod 420, $file; chmod 0x1a4, $file;
Boris

Replies are listed 'Best First'.
Re: Re: Unwanted Octal to Decimal Conversion
by djantzen (Priest) on Feb 18, 2004 at 21:44 UTC

    The reason I like this is that it makes evaluation of permissions in the code much simpler because they are already in octal form. Thus my permssions checking can do bitwise operations without having to reformat them. The code that writes to the database now uses oct so in the db the permissions are in decimal form.


    "The dead do not recognize context" -- Kai, Lexx
      The reason I like this is that it makes evaluation of permissions in the code much simpler because they are already in octal form. Thus my permssions checking can do bitwise operations without having to reformat them.

      Why would you have to "reformat" them to do bitwise operations? octal 040 and decimal 32 have exactly the same bit pattern.