rewriting checks in Perl