in reply to Call Perl script from Javascript

You haven't given very much information, however:

Assuming your server supports Perl scripts the same way it does PHP, "simply" replace the PHP script with a Perl script. In your Perl script, use the CGI module to handle input from the HTML page, or a more modern framework such as Mojolicious. For database connections, DBI and friends, or something more modern such as DBIx::Class. For returning things back to JavaScript, you may find a module such as JSON useful.

There are also plenty of tutorials on topics such Perl CGI scripts and database access, Google is your friend.