in reply to DBD::Pg - function declaration and using alias $n

See DBD::Pg and the $dbh->func( ... 'putline' ) function. This will allow you to send arbitrary text to the PostgreSQL server.

$dbh->func( q{ CREATE FUNCTION poo (INTEGER) RETURNS INTEGER AS $func$ DECLARE val ALIAS FOR $1; BEGIN RETURN val * 2; END } => 'putline' )