initial import of perl server function heavily inspired by http://people.planetpostgresql.org/xzilla/index.php?/archives/290-The-web-IN-your-database.html