Running Perl scripts under cPanel is fairly simple – actually pretty much the same as running anything that can be executed with CGI.
First thing’s first, your perl script needs to know its interpreter (this will allow you to make your perl scripts executable via the command line too, by the way).
Add this line to the top of your script:
This is called a “hash bang”. It’s used to tell the caller what executable should be used to run the code in the file. In this case, that file is /usr/bin/perl, the perl interpreter.
Note: Run the command “whereis perl” to double check the path of the perl interpreter.
You’ll also need to make your script executable. Run this command:
chmod +x /home/username/public_html/cgi-bin/file.pl
Your perl file should be in your public_html/cgi-bin directory. If you would like the script to run outside the cgi-bin directory, place the following content into an .htaccess file in the directory you’d like to use:
Options +ExecCGI AddHandler cgi-script .pl