# Perl script basics

> Get the basics of running Perl scripts on your hosting account, including permissions, file extensions and the Perl path.

Source: https://helpcenter.ruachost.com/developers/programming-languages/perl-script-basics/

This guide covers the essentials for running Perl scripts on Ruachost servers, including permissions, file extensions, and execution.

## File Permissions for Perl Scripts

- **Web-accessible scripts:** Set permissions to `755` (read, write, execute for user; read and execute for group and others).
- **Command-line only scripts:** Set permissions to `700` (read, write, execute for user; no permissions for group and others).

> **Note:**
If a script needs to write to a file (e.g., guestbooks or bulletin boards), the target file can have `644` permissions (read/write for user, read-only for group and others).

## File Extensions

- **.cgi** – Use for Perl scripts that generate web output accessible to the public.
- **.pl** – Use for scripts run only from the command line or that do not generate web output.

## Perl Version

- To check the Perl version on your server, run `perl -v` over SSH.
- To check the version from the command line:

```
perl -v
```

## Path to Perl Executable

- Absolute path: `/usr/bin/perl`
- `/usr/bin` is in the default PATH, so you can usually run scripts like this:

```
perl filename
```

## FTP Transfer Mode

- Always use **ASCII mode** when uploading Perl scripts via FTP.
- Uploading in binary mode can cause errors such as:

```
Internal Server Error: Premature End of Script Headers (500)
```

## More Information

For official Perl documentation, visit [Perl Docs](http://www.perl.org/docs.html).
