I want to take $file1 and give it the same permissions as $file2, which may be owned by another user. Perl's stat() function returns the mode, but it's not obvious how to get from the 5-digit decimal number returned to octal values (executing oct($mode) on it doesn't give a sensible value). So, how do you do the conversion?