Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Conceptualizing

by chromatic (Archbishop)
on Dec 16, 2001 at 07:20 UTC ( #132298=note: print w/replies, xml ) Need Help??

in reply to Conceptualizing

I'm confused by some of your terminology. When you say you have scripts, do you mean that each is invoked by a separate user request? Or are you using do or require or some other method to accomplish things in the same request?

If the former (which I suspect to be the case), you may not be getting the data because you're not passing it as form or query string parameters. Just a guess, though your redirect appears to be okay.

To explain the new() call, you have to know a little bit about object oriented programming. An object is a bundle of data that has associated behavior. That's it. The data, in this case, is the data from the user request. The behavior are subroutines like redirect() and param().

When you call new(), the CGI module grabs the data and performs a little magic to make an object, then returns that to you. If you call new() again within the same process, you'll run into trouble -- the existing data has been used up to create the first object.

Does that make more sense? That's why I'm a little confused by your terminology.

Replies are listed 'Best First'.
Re: Conceptualizing
by Spenser (Friar) on Dec 16, 2001 at 08:21 UTC

    I probably should be ashamed to say this, but I tend to use the words script and program interchangably.  However, I think that the word script is appropriate here as you're (chromatic) implying:  Each of my .cgi files have minimal functions (keeping with Unix Philosophy).  Some create a web page for displaying a "form" for the user to fill out and "submit" for "post"ing.  Some read in data from previous scripts (via and HTML forms and some parsing I ripped off from O'Reilly--subparseform.lib) and process the data (e.g., update a mySQL database).  I do have some "require" lines that call upon a couple library (.lib) files that contain common functions.  Maybe these are causing me trouble.

    Alright, now we're getting complicated and getting involved too much in fixing my immediate problem, which isn't as important for me as my grasping the concept of "new CGI" (and I guess from what you're telling me, object oriented programming).  Grasping the concept, I believe, will solve the immediate problem and future ones.

    You mentioned that if I call new() within the same process, I'll run into trouble.  This seems to be the effect (the trouble, that is) that I'm experiencing.  It also seems to be touching on the subtle conceptual aspect that I was suspecting:  namely, although I may use new() in two separate .cgi files, by passing data from one to the other in this object bundle, as you put it, or $q, as I coded it, am I wiping out the data within $q with another new() in the second script by invoking it before I can parse the data into my string variables?  Boy, that was a long-winded question.  Put simply, if I were to alternate from $q and $x, or if I were to not declare new() until after I parse and save my data into string variables, would that solve my problem?  Okay, another long-winded sentence--it seems unavoidable for me when discussing such a concept and trying to apply it.  I'll stop here and let you and others respond, if you all would be so kind.

    Oh, and thanks for all of the postings thus far.  They have been helpful.  I've been playing with the practical suggestions and pondering the conceptual ones.  I think I'm getting closer.  Of course, that may yet to be determined.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2022-08-14 11:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found