# SQL create table _perlsub (name text,code text); insert into _perlsub (name,code) values ('get_time', 'my $x=shift; scalar localtime $x'); # PERL # invoke code for any function, assume strict, $dbh is active, error checking omitted for brevity my $func='get_time'; my $arg=1226940421; my %perlsubs; unless (exists $perlsubs{$func}) { # cache compiled subs my $sth=$dbh->prepare("select code from _perlsub where name='$func'"); $sth->execute(); my $code=$sth->fetchrow; $sth->finish; eval "$perlsubs{$func}=sub $func { $code }"; } print $perlsubs{$func}->{$arg}; # prints Mon Nov 17 16:47:01 2008