To change from decimal to octal, you can use sprintf with a %o format string
my $val = sprintf( "%o", 8 ); print $val; 10 ----- Original Message ----- From: "zentara" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, February 13, 2002 5:20 PM Subject: octal file permissions > > I'm trying to save file permissions with stat, > so I can restore permissions back to the file > after editing. > > my $mode = (stat $open)[2]; > > #and then later > > chmod $mode,$open; > > The program is working, but it has caused > me to wonder what is going on with the octal permissions. > > For instance, if I have a file with permissions 100500, > (stat file)[2] will report mode to be 33088. > > Ok, I can understand that because 33088 = oct(100500) > but given the octal number 33088 what function do I use > to convert it to 100500? In other words what is the > procedure to do octal to decimal conversion? > > Also, I thought that the 0500 style of given file permissions > IS octal. > So the docs tell me to do a chmod like this with octal values: > chmod 0500, file > > but in my program I'm using 33088 as the octal value? > > futher confusing the issue for me is that > oct(0500) = 208 > 8 is not supposed to be in the octal digit set of 0 to 7? > WTF?? > > Is there some easy to grasp perspective on this? > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]