That works fine if access control is done solely by the standard permission bits. It fails is access control is done via ACLs, which allows making a file writeable for more than the owner of a file, without having to resort to groups. (One can only be a member of a limited number of groups, a number that quickly exceeds the number of permutations of a small group of people wanting to share files)
AFAIK, there's no way to ACL querying with just standard Perl. But I'd be surprised if there aren't CPAN modules available that will do ACL management for the more common systems out there (but I haven't checked).