rewriting client checks in Perl