Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to find and fix problems in your Perl scripts

This guide shows you how to find out why a Perl script on your hosting is not working, and how to fix the most common problems.

Windows Hosting3 min read9 steps

What is a Perl script?

Perl is a programming language. A Perl script is a text file with Perl instructions. On a website, scripts usually end in .pl or .cgi. CGI means the web server runs the script and sends back what it prints, like a cook who follows a recipe and hands you the dish.

The most common error you will see is "500 Internal Server Error". It is a general message that means "something went wrong inside the script". It does not tell you what. So you need to look for clues.

Steps

  1. Check the first line of the script. It must point to Perl, for example #!/usr/bin/perl. This line is called the shebang. It tells the server which program should run the file. The correct path for your server is in your welcome email, or you can ask Hostvento support.
  2. Make sure the script prints a header before any other output. Add this line before everything else you print:
    print "Content-type: text/html\n\n";
    This line tells the browser what kind of data is coming. Without it you get a 500 error.
  3. Check the file permissions. A permission is a rule about who may read or run a file. Most scripts need the value 755. Use your File Manager or an FTP program, right-click the file and choose the permissions option.
  4. Check the line endings. If you wrote the file on Windows and uploaded it in the wrong mode, the server may not read the first line. Upload the file again in ASCII mode (text mode) in your FTP program.
  5. Test the script for syntax mistakes. Syntax means the spelling and grammar of code. If you have SSH access (a safe way to type commands on the server), run:
    perl -c yourscript.pl
    This only checks the script. It does not run it. It prints "syntax OK" or tells you the line with the mistake.
  6. Run the script by hand to see its real output:
    perl yourscript.pl
    Any error message appears right on the screen.
  7. Look at the error log. A log is a diary that the server keeps. Look for a file named error_log in the folder of your script, or use the Errors or Metrics section of your control panel if it has one.
  8. Add the strict and warnings lines near the top of the script:
    use strict;
    use warnings;
    They make Perl point out careless mistakes, such as a misspelled variable name.
  9. Check that every module the script uses is installed. A module is an add-on that gives Perl extra skills. If the log says "Can't locate" and a module name, ask Hostvento support whether it can be installed on your plan.
Tip: Change one thing at a time and test after each change. Then you will know which change fixed the problem.

Quick recap

  • A 500 error only says something is wrong. Look at the logs for the reason.
  • Check the shebang line, the Content-type header, and permissions of 755.
  • Use perl -c to test syntax and use strict; use warnings; to catch mistakes.
  • Upload scripts in ASCII mode.
  • If a module is missing, ask Hostvento support.