rewriting remote checks in Perl