Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8578801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:28:33+00:00 2026-06-11T20:28:33+00:00

I have a perl -cgi script in which I need to test something based

  • 0

I have a perl -cgi script in which I need to test something based on when cgi_error() happens. Could some one please let me know under what scenario cgi_error() function gets invoked. I tried below

  1. changed owner and permissions on the script

But that has not helped so far.

This is code snippet

use CGI qw(-compile :standard);
.....

 if (cgi_error()) {
...
}

It would be great if some one can explain when cgi_error() is invoked automatically in the script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:28:34+00:00Added an answer on June 11, 2026 at 8:28 pm

    The cgi_error is not called “automatically”. However, depending on the circumstances, it will return information to see if something went wrong.

    From the CGI documentation:

    RETRIEVING CGI ERRORS

    Errors can occur while processing user input, particularly when processing uploaded files. When these errors occur, CGI will stop processing and return an empty parameter list. You can test for the existence and nature of errors using the cgi_error() function. The error messages are formatted as HTTP status codes. You can either incorporate the error text into an HTML page, or use it as the value of the HTTP status:

    my $error = $q->cgi_error;
      if ($error) {
        print $q->header(-status=>$error),
        $q->start_html('Problems'),
        $q->h2('Request not processed'),
        $q->strong($error);
        exit 0;
      }
    

    When using the function-oriented interface (see the next section), errors may only occur the first time you call param(). Be ready for this!

    and

    Handling interrupted file uploads

    There are occasionally problems involving parsing the uploaded file. This usually happens when the user presses “Stop” before the upload is finished. In this case, CGI.pm will return undef for the name of the uploaded file and set cgi_error() to the string “400 Bad request (malformed multipart POST)”. This error message is designed so that you can incorporate it into a status code to be sent to the browser. Example:

    $file = $q->upload('uploaded_file');
      if (!$file && $q->cgi_error) {
        print $q->header(-status=>$q->cgi_error);
        exit 0;
      }
    

    and

    An attempt to send a POST larger than $POST_MAX bytes will cause param() to return an empty CGI parameter list. You can test for this event by checking cgi_error(), either after you create the CGI object or, if you are using the function-oriented interface, call param() for the first time. If the POST was intercepted, then cgi_error() will return the message “413 POST too large”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a perl script (Cgi / Apache / Windows) which executes some programs
I have simple Perl/CGI scripts based web server which is mainly used to display
I have written a Perl CGI script which fetches an html page from a
I need to have a Python CGI script do some stuff (a little bit
I have a need to upgrade a Perl CGI script where the users must
I have a perl script using CGI. The browser calls it with some parameters.
I have a perl cgi script that's fairly resource intensive (takes about 2 seconds
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I have this Perl script sitting in the cgi-bin folder of my Apache server:
i have something like: #!/usr/bin/perl use strict; use warnings; use CGI::Simple; use DBI; my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.