Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: CGI Action call

by tultalk (Monk)
on Mar 12, 2018 at 13:08 UTC ( [id://1210711]=note: print w/replies, xml ) Need Help??


in reply to Re: CGI Action call
in thread CGI Action call

Hi: Thanks

I am not calling a "function" (sub something() . I and calling ?action=four&in=6 and that labeled block of code cannot return anything (error) as it is not a sub. Seems a shortcoming to me since these action= in this case are really subs just called in a different manner.

Further, how do you call a sub directly using the MyCGI.cgi call?

Replies are listed 'Best First'.
Re^3: CGI Action call
by pryrt (Abbot) on Mar 12, 2018 at 13:41 UTC

    ?action=four&in=6 is not a labeled block of code in your CGI application. Those are parameters passed to the CGI. Your application could "handle" them by running an inline block of code, or by calling a function, or by completely ignoring them. You haven't provided an SSCCE, so we cannot know how you chose to handle them.

    Speaking on the philosophical level, to "return" anything in a CGI environment, you print the headers and the "anything" to STDOUT: If your CGI is supposed to output HTML, then you print headers followed by HTML to STDOUT; if your CGI is supposed to output JSON, then print the headers followed by the JSON text; if your CGI is supposed to output an image, your script needs to print the headers then the (possibly-encoded) binary for the image; if your CGI is supposed to output an error message, your script needs to print headers then the error message. For the error condition, if you want the message to just be part of the normal response, then included it as part of the already-existing message: for example, give some normal HTML, but include a <p class=error>error message goes here</p> or similar at an appropriate location in the HTML output; or, in the case of an image, include your normal pixels for the image, but then overwrite some of the pixels with your error indicator, before printing the image bytes to STDOUT.

    If this is not helpful, you are going to have to give an SSCCE and a better description of what your current code outputs, and how you'd like to modify that output under the conditions you will need to specify.

Re^3: CGI Action call
by poj (Abbot) on Mar 12, 2018 at 13:54 UTC

    Are you talking about returning data from one cgi script 'called' from another cgi script ?

    poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1210711]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-16 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found