scoring function implemented with Perl