Perl factorization