Skip to main content

Header Reseller Branding

  • Home
  • Frequently Asked Questions
    • Logging into the Control Panel
    • Changing Name Servers of a Domain Name
    • Managing DNS Resource Records
    • Using the Web Hosting Service
    • Explaining Domain (Transfer) Secret or Authorization (Auth) Code and How to Obtain it from your Current Registrar?
    • Transferring a Domain Name from Another Registrar to Answerable.com
    • Domain / URL Forwarding
    • Customer Control Panel Guide
    • Registering and Managing Child Name Servers
    • Using the DNS Service
    • DNS and types of Resource Records Answerable.com allows
    • Using the Free Email Service
    • Listing, Searching and Managing Domain Name Registration Orders
    • Uploading Content to your Website
    • Moving or Pushing a Domain Name from one Customer Control Panel to another
    • What are the permitted Countries of Operation?
  • Logging into the Control Panel
  • Domain Names
    • Listing, Searching and Managing Domain Registration Orders
    • Changing Name Servers of a Domain Name
    • Managing Whois or Contact Details of Domain Names
      • Modifying the Whois (Contact Details) of Domain Names
      • Modifying the Whois / Contact Details of a .UK Domain Name
      • Managing Contacts from within the Customer Control Panel
      • Hiding Contact Details through Privacy Protection in the Whois of a Domain Name
        • Defining Privacy Protection
        • How can People Contact you if you Enable Privacy Protection for your Domain Name?
        • Purchasing / Renewing Privacy Protection
        • Enabling/Disabling Privacy Protection for a Domain Name
        • How can you Enable/Disable Privacy Protection of Multiple Domain Names?
      • Resellers: Controlling the display of your Brand Name in the Whois Lookup Results for .COM / .NET Domain Names
      • Checking the Whois for a Domain Name
      • Hiding/Publishing Registrant Organization in the Whois of a Domain Name
      • Hiding/Publishing Contact Details in the Whois of a .TEL Domain Name
      • Hiding/Publishing Contact Details in the Whois of a .CA Domain Name
    • Hiding Contact Details through Privacy Protection, in the Whois of a Domain Name
    • GDPR
      • What is GDPR?
      • Managing GDPR Protection settings
    • Transferring a Domain Name
      • Confirming if a Domain Name can be Transferred
      • Transferring a Domain Name from Another Registrar to Answerable.com
        • Explaining Domain (Transfer) Secret or Authorization (Auth) Code and How to Obtain it from your Current Registrar?
        • Transferring your Domain Name
        • Transferring a .UK Domain Name
        • Bulk Transfer
        • Cancelling a Domain Name Transfer
        • Important - Domain Name Transfer Caveats
      • Transferring a Domain Name from Answerable.com to Another Registrar
        • Transferring a Domain Name to Another Registrar
        • Transferring a .UK Domain Name to Another Registrar
        • IMPORTANT: Domain Name Transfer Caveats
        • Fast Transfer
          • What is fast transfer?
          • How do I opt-in my domain name for Fast Transfer?
          • How do I find and opt-out names from the Fast Transfer service?
      • Domain Name Transfer Caveats
        • Understanding the Status of a Domain Name Transfer
        • Lost One Year when Transferring a Domain Name from One Registrar to Another
        • Domain Name Transfer Completed but Domain Name is Still Inactive
      • Locating and Modifying the Domain (Transfer) Secret/Authorization Code for a Domain Name
    • Deleting a Domain Name
    • Protecting/Locking a Domain Name
    • Domain Protect+
    • Registering and Managing Child Name Servers
    • Suspending / Unsuspending Domain Names
      • Suspending / Unsuspending a Domain Name
      • Bulk Suspension / Unsuspension of Domain Names
    • Renewing Domain Names
      • Renewing a Domain Name
      • Bulk Renewal of Domain Names
      • Understanding Domain Name Expiry and Display of a Parking Page
    • Domain Name System Security Extensions (DNSSEC)
      • What is DNSSEC?
      • Adding Delegation Signer (DS) Records
      • TLDs supporting DNSSEC
    • Domain Name Registration Default Settings
    • Viewing Action History
    • Restoring a Deleted Domain Name from the Redemption Grace Period
    • Domain Name Registration Caveats
      • Overview of TLDs (Domain Name Extensions)
      • Interpreting Domain Name Check Availability Results
      • Interpreting Order Locked In Processing Messages
      • Support for Internationalized Domain Names (IDN)
      • .ASIA Domain Name Rules/Requirements
      • .CA Domain Name Rules/Requirements
      • .CO Domain Name Rules/Requirements
      • Understanding .EU Domain Names
        • .EU Domain Name Rules/Requirements
        • Understanding .EU Domain Name Contacts
      • .JOBS Domain Name Rules/Requirements
      • .ME Domain Name Rules/Requirements
      • .MOBI Domain Name Rules/Requirements
      • .NAME Domain Name Rules/Requirements
      • .NZ Domain Name Rules/Requirements
      • .PRO Domain Name Rules/Requirements
      • .PW Domain Name Rules/Requirements
      • .SC Domain Name Rules/Requirements
      • .TEL Applications
      • .TEL Domain Name Rules/Requirements
      • .UK Domain Name Rules/Requirements
      • .US Domain Name Rules/Requirements
      • .VC Domain Name Rules/Requirements
      • .CO.ZA Domain Name Rules/Requirements
      • .IN Restricted Email List
      • Identifying CentralNic Domains
      • Premium Domains
      • Sunrise Period
      • Identifying New gTLD Extensions
      • New gTLD Wishlist
    • Whois Data Verification
    • Whois Data Reminders
    • DNS
    • Domain / URL Forwarding
    • Domains Product Maintenance Notices
  • Hosting
    • Single Domain Linux Hosting
      • Accessing your Single Domain Linux Hosting Package
      • IMPORTANT: cPanel Single Domain Linux Hosting Package User Guide
      • RESELLERS: Read this to Setup your Single Domain Linux Hosting Business
    • Single Domain Windows Hosting
      • Accessing your Single Domain Windows Hosting Package
      • IMPORTANT: Plesk Single Domain Windows Hosting Package User Guide
      • RESELLERS: Read this to Setup your Single Domain Windows Hosting Business
    • Legacy Web Hosting
      • Using the Web Hosting Service
      • Listing, Searching and Managing Web Hosting Orders
      • Web Hosting Service Guide
        • How can I view my website in a browser if my domain is pointing elsewhere?
        • SSL
          • Issues that Digital Certificates Address
          • Activate SSL for your Hosting Package
          • Certificate Authority
          • Generating a Certificate Signing Request (CSR)
          • Installing your Digital Certificate
          • Generating a Self-signed Certificate
          • Uninstalling your Digital Certificate
          • Installing your Intermediate CA Certificate or CA Bundle
        • Back-up your Website
          • Adding a Backup Policy
          • Listing/Modifying and Deleting Backup Policies
        • Domain Aliases
          • Domain Alias
          • Adding Domain Aliases
        • Managing your Plesk Windows Hosting package
          • Accessing/Managing your Plesk Windows Hosting package
          • IMPORTANT: Plesk Windows Hosting package User Guide
        • Managing your cPanel Linux Hosting package
          • Accessing/Managing your cPanel Linux Hosting package
          • IMPORTANT: cPanel Linux Hosting package User Guide
          • Migrating your cPanel Linux Hosting package from another Web Hosting company to Answerable.com
      • Upgrading / Downgrading a Web Hosting Order
      • Legacy Web Hosting Deprecation
      • DNS for Web Hosting
    • Sample Scripts
      • Linux Hosting related Scripts
        • PHP-based Form Mail (Feedback) Script
        • Perl-based Form Mail (Feedback) Script
        • PHP Script to Test MySQL Database Connectivity
      • Windows Hosting related Scripts
        • Collaboration Data Objects (CDO)
        • ASP Script to Test MSSQL Database Connectivity
    • Uploading Content to your Website
      • Configuring and using various FTP Clients
        • Should I use Active or Passive mode for FTP?
        • Using FTP software to manage your Content
          • CuteFTP
          • Core FTP
          • SmartFTP
          • WinSCP
          • FileZilla
      • File/Folder Permissions and Groups
      • Do you allow Anonymous FTP?
    • Email Hosting
      • Using the Email Hosting service
      • Email Administrator's Guide - Create and Manage Accounts
        • Managing Mailing Lists
      • Email User's Guide - Access your Email
        • Configuring different Email Clients to send/receive Email
        • Accessing your Email from the Webmail Interface
        • Auto-responders
      • Email Hosting Caveats
        • File extensions that are not allowed as attachments
      • DNS for Email Hosting
      • Domain / URL Forwarding for Email Hosting
      • Personal Email Deprecation
    • Website Builder
      • Setting up your Website Builder Order
      • RESELLERS: Read this to Setup your Website Builder Business
      • DNS for Website Builder
    • Hosting Caveats
      • Purchasing a Hosting Order for Internationalized Domain Name (IDN)
      • Modifying the hosts file
      • Ports open for outgoing connections
      • Debugging Perl/CGI Scripts
      • SMTP Server settings for sending mails through your website
      • Switching PHP Version
      • Shared Hosting Limitations
      • SSH Access
      • SymLinks Settings of cPanel Linux Hosting packages
      • Creating and Restoring Backups in cPanel
      • Creating and Restoring Backups
      • Restriction on upload of executable files under Windows Hosting
      • HTTP to HTTPS Redirection - Apache
      • HTTP to HTTPS Redirection - IIS
      • How do I set the default page?
      • How do I unblock port 80/443 ?
      • How do I add custom error pages for Linux hosting?
      • How do I add custom error pages for Windows hosting?
      • Enable Cloudflare on cPanel
      • Varnish
      • How do I change the Primary domain of my hosting plan?
      • Managing registered email address for scripts
      • Unblocking Email Accounts in cPanel
  • Order Management
    • Listing, Searching and Managing your Orders
    • Locating the Name Servers or DNS Records to Use
    • Directory and File Structure - Linux
    • Directory and File Structure - Windows
    • Enabling SSL or a Dedicated IP Address
    • Renewal Reminder for Orders
    • Renewing, Deleting your Order
    • Upgrading / Downgrading an Order
    • Suspending / Unsuspending an Order
    • Moving or Pushing an Order from one Customer Control Panel to another
    • Bulk Actions
      • Registering Domain Names in Bulk
      • Transferring Domain Names in Bulk
      • Renewing Orders in Bulk
      • Suspending or Unsuspending Orders in Bulk
      • Locking or Unlocking Domain Names in Bulk
      • Modifying Name Servers in Bulk
      • Modifying Contacts in Bulk
      • Enabling / Disabling Theft Protection in Bulk
      • Privacy Protecting Domain Names in Bulk
      • Moving Domain Names in Bulk
      • Listing All Running Bulk Actions
  • DNS
    • DNS and types of Resource Records Answerable.com allows
    • Using the DNS Service
    • Locating the DNS Service Interface
    • Managing DNS Resource Records
    • DNS Caveats
      • No NS A records at Nameservers Failure Message
  • Accessing your Domain Backorder
  • Domain Backorder Setup Guide
  • FAQ
  • Domain / URL Forwarding
    • Using the Domain Forwarding Service
    • Locating the Domain Forwarding Service Interface
    • Managing the Domain Forwarding Service
    • Domain / URL Forwarding Caveats
      • No NS A records at Nameservers Failure Message
  • Free Email Service
    • Using the Free Email Service
    • Locating the Free Email Service Interface
    • Managing the Free Email Service
    • Free Email Service Caveats
      • No NS A records at Nameservers Failure Message
  • Customer Control Panel Guide
    • Creating a Demo Customer Account
    • Logging into the Control Panel
    • Your Profile and Settings
      • Changing your Control Panel Username, Mobile Number and other Contact Details
      • Changing your Control Panel Password
      • Changing your Personal Identification Number (PIN)
      • Setting your Email Preferences
      • Setting your SMS Preference
      • Setting your Language Preferences
    • 2-Step Verification
      • FAQs
      • How do I enable 2-Step Verification?
      • How do I disable 2-Step Verification?
    • Manage Billing
      • Adding Funds in your Debit Account
      • Executing an Order / Balancing an Invoice or Debit Note
      • Cancelling an Order / Invoice
      • Requesting Refund from Answerable.com
      • Listing / Searching your Transactions
      • Locked Funds
      • EU VAT FAQs
      • Service Tax FAQs
      • GST FAQs
      • VAT for Russia FAQs
    • Listing All Orders under your Customer Account
    • Viewing your Login History
    • Viewing all important Announcements posted in your Control Panel
    • Customer Control Panel Caveats
      • Restriction on Change of Country and Legal Name
      • Session Timeout

Debugging Perl/CGI Scripts

Hosting servers are configured to store error logs for CGI/Perl scripts, encountered during the course of operation. By default, error messages are sent to STDERR.

Most HTTPD servers direct STDERR to the server's error log, which stores information for all the websites hosted on a shared hosting environment. As this, this file cannot be accessed by individual website owners. You may wish to keep private error logs, distinct from the server's error log, or may wish to direct error messages to to a web browser.

This can be accomplished by coding your scripts accordingly during the development phase.

Sending error messages to a private log file

The carpout() function can be used to achieve this. Since carpout() is not exported by default, you must import it explicitly as -

use CGI::Carp qw(carpout);

 

The carpout() function requires one argument, which should be a reference to an open filehandle for writing errors. It should be called in a BEGIN block at the top of the CGI application so that compiler errors will be caught.

 

Example:

BEGIN {
use CGI::Carp qw(carpout);
open(LOG, ">>/domains/domain.com/logs/cgi-error.log") or
die("Unable to open cgi-error.log: $!\n");
carpout(LOG);
}

carpout() does not handle file locking on the log for you at this point.

 

Sending error messages to a Web Browser

 

Fatal (die, confess) errors can be sent to a web browser by importing the special "fatalsToBrowser" subroutine:

use CGI::Carp qw(fatalsToBrowser);
die "Couldn't open log file";

Fatal errors will now be echoed to the browser as well as to the log file. CGI::Carp arranges to send a minimal HTTP header to the browser so that even errors that occur in the early compile phase will be seen. Nonfatal errors will still be directed to the log file only (unless redirected with carpout).

 

Sample Script

#!/usr/bin/perl -wT

# In the first line above, T causes Perl to check
# for "tainted" data, that is, data from outside the
# script (i.e. user input) that is going to be used
# to affect something else outside the script
# (i.e. writing to a log file)

# You can untaint data by parsing it for unwanted
# characters then saving it to another variable.

# If you are having trouble with a script, try removing
# the T switch to see if that is the problem.

# The w switch in the first line causes warnings about
# script syntax to be printed, if there are any.

# This script does 2 things:
#
#1. It directs fatal errors to the browser,
# so when the script is invoked via the Web,
# a meaningful error message is returned.
# This is useful when developing a script;
# but should be disabled when the script
# is made publicly available.
#
# 2. It will direct any error message the script
# generates to an error log that resides in
# the user's home directory. The file must
# already exist and be "other" writeable.

# Notice that the following is enclosed in a BEGIN { }
# block that causes it to execute before the rest of
# the script is read.

# This block should be placed in the main script,
# as near the top as practical. Do not place it in
# subroutines or libraries. Always test
# subroutines thoroughly before placing them
# in libraries.

BEGIN {

# define an error log in YOUR home directory
# this is an example where the
# home directory is /domains/domain.com/

my $error_log = "/domains/domain.com/logs/cgi-error.log";

# "my" in the line above makes the variable $error_log
# local so it only has meaning inside this block.
# See your text for more on variable scope.

# load the CGI::Carp module;
# fatalsToBrowser directs fatal errors to the browser
# carpout is for directing errors to the error log

use CGI::Carp qw(fatalsToBrowser carpout);

open (LOG,">>$error_log") ||
die "couldn't open log file: $!";
carpout(LOG);

# open(...) is used to open a file.
# >> means the new input will be appended what's
# already in the file.

# LOG is a nickname (properly called a "file handle")
# that is given to the file so it is easy to refer to
# it later, i.e. carpout(LOG) sends the error
# message to the file with the nickname LOG

# || means "or" (as in do this or that)
# die means stop executing the program. You can add
# a message in quotes after the die command.

# $! is a special variable that contains the current error info

}

# The following line will cause an error.
# It is a call to a sub-routine that does not exist.
# After you have tried this script and received the error message,
# comment out the following line so no error occurs
# and "Hello world!" is printed.

&non_existent_subroutine();

print <<EOT;
Content-type: text/html\n\n

<HTML>
<BODY>
Hello world!
EOT

print "</BODY></HTML>";

 

Answerable.com