sub perm2mode { my( $perm )= @_; if( 9 != length($perm) || 9 != ( $perm =~ tr/rwx-/1110/ ) ) { die "Unsupported permission string ($_[0])"; } return unpack "v", pack "b*", ''.reverse$perm; }