rewriting check scripts in Perl