Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
03-12-2011, 01:07 PM #1
- Join Date
- Apr 2003
- in my house
- Thanked 201 Times in 197 Posts
trouble passing params to script - specific scenario.
been away for a while and am a bit rusty. I would appreciate a nudge with this issue, please.
I have a main script, which establishes a $db_connect and a $session.
It passes this to a doctype_and_header.pl - for outputting the, erm, doctype and the rest of the head section of the html output.
Doctype_and_head.pl works out the $css values from a db_connection and uses them in the following line:
print qq( <link rel="stylesheet" href="/cgi-bin/stylesheets.pl/$css1$css2$css3" type='text/css' media='screen' /> );
stylesheets.pl will load the existing $session using:
my $session = load CGI::Session($cgi) or die CGI::Session->errstr;
I imagine it's not secure to store the $db_connect in the $session, even if possible. I have tried but i get an overload warning.
And I wonder if establishing a connect specificallty for this script, is placing undue/unnecessary demands on the server.
So, should I make a connection for stylesheet.pl and terminate it at the end of this script (as soon as it is finished its db job), or, is it possible to pass the existing $db_connect from doctype_and_head.pl using the html line above (or some other way)?
Maybe there is a completely different way to output the css whilst keeping it as an external resource?
03-13-2011, 10:33 PM #2
- Join Date
- May 2005
- Southern tip of Silicon Valley
- Thanked 164 Times in 159 Posts
No, you can't pass the db object to another script like that; you'll need to create a new db object in stylesheets.pl.
My first choice would be to do the css db calls in doctype_and_header.pl and drop stylesheets.pl and my second choice might be to do the db calls in stylesheets.pl.
A much better choice for many reasons would be to use either Mason or Catalyst.