I know I'm not supposed to say thanks here.  But the open source/Perl
community has really impressed me with their willingness to help those less
knowledgeable.  Its nothing short of amazing in my experience. When I first
started the prototype work I've been doing, I called the public U. of Ky
Computer Science Department and asked if I could get a little guidance as I
was just transitioning into the WWW world.  The faculty I talked to ask me
if this was a consulting request.  When I responded that I had hoped to just
be able to ask a couple of questions, the person told me that they weren't
in the business of answering questions from the public without remuneration.  
I'm just an individual and could not afford their fees.   What a contrast.   
Thanks for the guidance and letting me learn from you all Perrin, Peter, and
Clinton over in Perl Monks, and everyone else that responded.   CraigT



Perrin Harkins wrote:
> 
> On 7/6/07, CraigT <[EMAIL PROTECTED]> wrote:
>> In this regard though, I would
>> like to ask what you recommend to pass back several paramters from a sub
> 
> The usual way to do it is to accept a list of return values:
> 
> my ($foo, $bar) = sub_call($param);
> 
>> I'd like to focus on this problem here because I don't feel like I have
>> much
>> control between the anchor click and the retrival of the paramters in the
>> invoked module.
> 
> You don't have any control of that.  That's handled by the web browser
> and your operating system.  We just assume that part works.  I don't
> think the problem is there.
> 
>> I haven't shown the code because I'm not quite sure how.
> 
> The best thing to do is to try to make a small example program that
> shows the problem.  Sometimes, just by trying to make a small example
> of it, you fix the problem.
> 
>> The first module presented is m3.cgi.
> 
> This code has some problems.  This isn't a general Perl help mailing
> list, but I'll point out a couple of quick things.  I also recommend
> that you buy a copy of "Perl Best Practices" and join
> http://perlmonks.org/ in order to have a community of people to help
> you with general Perl questions.
> 
>> use strict;
> 
> Use warnings too.
> 
>> (my $ai, my $row, my $r, my $col, my $c, my $cpos, my $blankx, my $lstr,
>> my
>> $xlnklen, my $zzx, my $firstcpos) = "";
> 
> This kind of initialization isn't necessary.  It's better to declare
> your variables right before you use them, to keep the scope as small
> as possible.  The way you're initializing them here won't work anyway,
> since you only have one empty string, and a list of variables on the
> left.
> 
>> # Get document root and server name.
>>
>> foreach $key (sort keys(%ENV)) {
>>       if ($key eq 'DOCUMENT_ROOT') {
>>         $docroot = $ENV{$key};
>>       }
>>
>>       if ($key eq 'SERVER_NAME') {
>>         $servname = $ENV{$key};
>>       }
>> }
> 
> That should just be
>   $docroot       = $ENV{DOCUMENT_ROOT};
>   $servername = $ENV{SERVER_NAME};
> 
>> open(ORG,"<$orgidfn");
>> flock(ORG,LOCK_SH);
>> @glines = <ORG>;
>> close(ORG);
> 
> Any time you open, flock, or close, you must check for errors with the
> usual "or die" construct.
> 
>>   print "Content-type:  text/html\n\n";
> 
> Use $page->header() instead.
> 
>>   print "<HTML><HEAD><TITLE>$gov Efforts</TITLE>
> 
> A templating system might make this HTML easier for you to deal with.
> You could start with something simple, like Text::Template.
> 
>> # Get the paramters from the calling program - shoidls.cgi.
>>
>> $govlevel = $page->param("str");
> 
> I don't see anything wrong with this, or with the call where you
> created $page, above.  Put in a "warn $govlevel" there and see if it's
> what you think it should be.  If it is, manually change the value of
> str in the URL in your browser and try it again, checking to see if
> the variable changes too.
> 
>> If I preload (compile) my application programs into the Apache registry
>> as I
>> hope to, when I execute under CGI I'm thinking those copies will be used
>> if
>> I have the correct handler (like the one below) in my Apache httpd?
> 
> Well, you won't be executing under CGI, but if you configure Registry
> to handle your URLs and you preload scripts for those URLs, they will
> be used.  Your configuration is not correct though.  Apache::Registry
> is mod_perl 1.  Maybe you meant to say ModPerl::Registry?
> 
>> I
>> haven't found a package for Apache::RegistryLoader yet and may have to
>> get
>> it form CPAN.
> 
> No, ModPerl::RegistryLoader comes with mod_perl 2.
> 
>> And when I transition to PerlRun and mod_perl, my
>> understanding is that I should preload the application programs into the
>> ModPerl::Registry?
> 
> You don't really have to preload anything.  It may save you some
> memory, but it's not important at this point.  Wait until your code is
> working to worry about things like that.
> 
>> If I preload the Perl modules I'm using, do I still need to 'Use' those
>> modules in my application programs?
> 
> You don't technically have to, but it's a good practice to do it
> anyway, to make it clear which modules depend on which others and make
> it easier to work with later.
> 
> - Perrin
> 
> 

-- 
View this message in context: 
http://www.nabble.com/passing-CGI-paramters-tf4008753.html#a11478312
Sent from the mod_perl - General mailing list archive at Nabble.com.

Reply via email to