Re-implementing functions in PL/Perl