Forum Moderators: coopster & phranque

Message Too Old, No Replies

passing a value to a module from a cgi

         

jeremy goodrich

6:43 pm on Dec 22, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do I go about this? I've been trying for a bit, gave up, and realized I still need to work out how I'm going to accomplish this.

I've got a cgi which reads a file, and for each line, produces a html page. There are modules which handle various aspects, and I'm trying to pass data to each module so that it can work on on the data from the file that is read in, one piece at a time...

would this pass to a module the piece of data?

$myvariable = moduleFunction->routineName($value)

where $value is the value from the first line that is read in at the start of the cgi...there is a foreach which handles that well.

how do I get ($value) into the module moduleFunction as in the example? thanks.

jeremy goodrich

7:26 pm on Dec 24, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hm, found out elsewhere this was my problem:

in the module code:
($value) = @_;

when you need to remember that ($new, $value) = @_; because first the script passes implicitly the new module object, and then the variable I was trying to pass to the module.

:) perhaps eventually I'll be able to code something.

jeremy goodrich

9:36 pm on Dec 27, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



new problem, related:

I can pass the value to the external module just fine from the cgi script, but when the value changes, the module doesn't get the new value, it just spits out the same old one...any ideas on how to correct this? Thanks

sugarkane

9:18 am on Dec 28, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure what the problem could be here Jeremy. It could be variable scoping - are you using my $foo=@_; within the module?

I use a slightly different technique and syntax (here [webmasterworld.com]) - it might be worth trying it this way and seeing what happens.

jeremy goodrich

11:43 pm on Dec 28, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yep, it was a scoping error. thanks for the reference, I actually strolled through some perl documentation, found out my mistake, and corrected it the other day :) I've got a new problem now though...