# Troubleshooting Perl scripts

> Fix Perl scripts that will not run by checking permissions, line breaks, command-line output and web server error logs.

Source: https://helpcenter.ruachost.com/developers/programming-languages/troubleshooting-perl-scripts/

This guide outlines a four-step process for troubleshooting Perl scripts and resolving common issues.

### Step 1: Verify file permissions

Ensure the Perl script has the correct file permissions:

- **Web-accessible scripts:** `755`
- **Command-line only scripts:** `700`

Incorrect permissions are a common cause of script failures.

### Step 2: Verify line break settings

Check that the Perl script uses **UNIX text format**, not DOS format.

- UNIX and DOS formats handle line breaks differently.
- Scripts saved in DOS format may produce syntax errors.

### Step 3: Run the script from the command line

Debugging via a web browser can hide error details. Running the script from SSH provides more useful information.

To run the script:

```
perl filename
```

For detailed debugging, use the Perl command-line debugger:

```
perl -d filename
```

The debugger provides line-by-line control and detailed error messages. More information is available at [Perl Debugger Tutorial](http://perldoc.perl.org/perldebtut.html).

### Step 4: Check web server error logs

This step applies only to CGI scripts accessed through a web browser.

- Scripts that produce `500 Internal Server Error` or `403 Forbidden` are logged in the web server error logs.
- Use cPanel to view your site’s error log for detailed information.

Following these steps helps identify common issues with Perl scripts and simplifies debugging.
