PERL: Inversion counts