in reply to Convert ls listing of -rwxr-xr-x into mode for stat
You could always just use Archive::Tar and get the mode directly without parsing anything.