Gossamer Forum
Home : General : Perl Programming :

Adding values to CGI.pm?

Quote Reply
Adding values to CGI.pm?
Hi. I am trying to work out how I would assign values to a new CGI object within a sub-routine. I am already running the sub, so there is not a posibility of using 'hidden' values in the HTML page before. Is this possible? I'm pretty sure I saw some code around once explaining how to do it, but I can't for the life of me find it now :(

I have looked at the documents here;

http://[1] http://search.cpan.org/author/LDS/CGI.pm-2.93/CGI.pm
http://[2] http://search.cpan.org/author/LDS/CGI.pm-2.93/CGI.pm#SETTING_THE_VALUE_S_OF_A_NAMED_PARAMETER_

...but the code I have made from these examples;

$IN->param( -name=>'SessionDate', -value=>$date );

...doesn't seem to be working Unimpressed

Anyone got any ideas? I know for a fact there is stuff about it in this forum, but I just can't find it :(

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Adding values to CGI.pm? In reply to
$IN->param( SessionDate => $date );
Quote Reply
Re: [Paul] Adding values to CGI.pm? In reply to
Cheers Paul..worked like a charm :)

I'm just wondering. I am getting a load of errors for some reason now.

Quote:
GT::Plugins (8595): Error running plugin PRE hook: Plugins::Add_RandImage::Make_Session. Reason: syntax error at /home/bn123/bn123.net/cgi-bin/portal/admin/Plugins/Add_RandImage.pm line 151, near "}}"
Global symbol "$hit" requires explicit package name at /home/bn123/bn123.net/cgi-bin/portal/admin/Plugins/Add_RandImage.pm line 152.
syntax error at /home/bn123/bn123.net//cgi-bin/portal/admin/Plugins/Add_RandImage.pm line 153, near "}"
Compilation failed in require at GT::Plugins::_load_hook line 261.
at /home/bn123/bn123.net/cgi-bin/portal/add.cgi line 25.

However, I define all the variables at the top of the routine, with;

Code:
my ($error,$hit,$randID,$table,$back,$true,$sth);

Is this a mod_perl thing? If I set the plugin up on a non-mod_perl enabled site, it works fine. I really do hate mod_perl Frown

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Adding values to CGI.pm? In reply to
The error tells you you have a syntax error. Looks like you have an extra } or something.
Quote Reply
Re: [Andy] Adding values to CGI.pm? In reply to
Why? Looks to me like you're not utilising mod_perl at all anyway, your probably just running your scripts through Apache::Registry.

- wil
Quote Reply
Re: [Paul] Adding values to CGI.pm? In reply to
Yeah, it turned out to be an extra } in an 'if' statement. I was just making sure it wasn't something to do with mod_perl, cos mod_perl is a pain in the arse to develop with Frown

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Adding values to CGI.pm? In reply to
Quote:
mod_perl is a pain in the arse to develop with

I don't consider forcing good coding style to be a bad thing =)
Quote Reply
Re: [Wil] Adding values to CGI.pm? In reply to
In Reply To:
Why? Looks to me like you're not utilising mod_perl at all anyway, your probably just running your scripts through Apache::Registry.

Its more the way it 'caches' pages, error etc. So you make a fix, it seems to work, then you get an error page again for no aparant reason. You then go back and try to fix it, but it turns out to be that mod_perl just needs restarting again Frown

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Adding values to CGI.pm? In reply to
Wow. What *are* you doing? :-)

- wil
Quote Reply
Re: [Andy] Adding values to CGI.pm? In reply to
I find it best to write the code under a normal CGI environment using strict, warnings and taint checking - that will catch most errors. Then when you load everything into mod_perl you should find most things work. It's much easier than restarting mod_perl after every edit.

When you first start making mod_perl compatible scripts you'll find weird things happening, but once you get to grips with the persistant environment it will start becoming clear what's going on and why.
Quote Reply
Re: [Paul] Adding values to CGI.pm? In reply to
That's not utlizing mod_perl at all, though, you're just running your regular scripts through Apache::Registry which gives you the same environment as a non mod_perl server. Well, with a few differences.

- wil
Quote Reply
Re: [Wil] Adding values to CGI.pm? In reply to
Quote:
That's not utlizing mod_perl at all, though, you're just running your regular scripts through Apache::Registry which gives you the same environment as a non mod_perl server. Well, with a few differences.

Sure it is. All Apache::Registry does is try to mimic the CGI environment (setup environment variables, etc). Your scripts are still running through the mod_perl server.

Paul is right though, develop your apps under regular cgi using strict and warnings. Once they are done and tested, then you move them to mod_perl.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Paul] Adding values to CGI.pm? In reply to
In Reply To:
I find it best to write the code under a normal CGI environment using strict, warnings and taint checking - that will catch most errors. Then when you load everything into mod_perl you should find most things work. It's much easier than restarting mod_perl after every edit.

Yeah..I'll remember that for future development Crazy

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Alex] Adding values to CGI.pm? In reply to
Why develop them under a non mod_perl environment and then move them? Why not just develop for mod_perl correctly at first?

- wil
Quote Reply
Re: [Wil] Adding values to CGI.pm? In reply to
Because mod_perl caches libraries, and so changes to your libraries requires restarting your mod_perl server which can be a pain during development. There are attempts to get around this (Apache::StatINC being one of them -- but I've had poor experiences with this, frequent seg faults).

Cheers,

Alex
--
Gossamer Threads Inc.