Refactor Perl to more closely match Cafe.