What is MIME type "application/x-perl"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

application/x-perl is a MIME type for files that contain Perl code. These files include instructions meant to be run by the Perl interpreter. They commonly use the PL extension.

This MIME type tells systems to execute the code rather than just display it. It is often used in environments where automated scripts process data or generate dynamic content.

Learn more about MIME types here.
For further details on Perl, check the official site here.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: application/x-perl    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="application/x-perl">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'application/x-perl');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

Why is my browser downloading the .pl file instead of running it?

Browsers cannot execute Perl scripts natively; they only display the output (like HTML) sent by the server. If your browser downloads the file, your web server is likely sending the raw application/x-perl file instead of executing it via CGI. You need to configure your server (e.g., Apache or Nginx) to run the script and send the result to the browser.

How do I configure Apache to handle application/x-perl?

To execute Perl scripts, ensure mod_cgi is enabled and add AddHandler cgi-script .pl to your httpd.conf or .htaccess file. The script must also have executable permissions (usually chmod 755) and a valid shebang line (e.g., #!/usr/bin/perl) at the very top.

What is the difference between application/x-perl and text/x-perl?

application/x-perl generally implies the file is an executable program or script intended to be run, often triggering a download if not processed server-side. In contrast, text/x-perl is typically used to indicate that the content should be treated as readable source code, often used for syntax highlighting or displaying the script in a browser.

Is application/x-perl a standard MIME type?

No, the x- prefix indicates that it is a non-standard or experimental type not officially registered with IANA. However, it is the de facto standard used by many legacy systems and web servers to identify Perl scripts associated with the .pl extension.

Are there security risks associated with this MIME type?

Yes, if a server is misconfigured, it might serve the raw code instead of executing it, exposing sensitive data like database passwords found in the script. Furthermore, allowing users to upload files identified as application/x-perl can lead to Remote Code Execution vulnerabilities if the server allows those uploaded scripts to run.

How do I serve Perl scripts using Nginx?

Nginx does not have built-in CGI support like Apache. To handle application/x-perl execution, you must use a FastCGI wrapper like fcgiwrap. You will need to configure a location block in your Nginx config to forward .pl requests to the FastCGI socket using fastcgi_pass.

Can I use application/x-perl for Perl Modules (.pm)?

While the MIME type technically describes the content, Perl Modules (.pm) are libraries meant to be included by other scripts, not executed directly via a web request. It is best practice to block direct web access to .pm files entirely to prevent source code disclosure.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.