Using PL/Perl for datatype abstraction