Completed p1 in Perl