Jonathan Mangin wrote:

> Jeez, this is a beginner's list? Y'all are defining my ignorance of this
> here purrl stuff. I hope someone with patience can help me out. In a
> simple login/registration program using 5.6.1...
> 
> #!/usr/bin/perl -wT
> use strict;
> 
> [CGI and DBI stuff]

IOW, important stuff removed.

> $countryid="1";
> $statename=$gotcha;
> @r_states=getStates([EMAIL PROTECTED], \%states1, \%states2);
> $stateid=$states2{$statename};
> @r_counties=getCounties([EMAIL PROTECTED], \%counties1);
> 
> if ($CGI->param("Register")) {
>    Register($CGI, \%$counties1);
> }
> elsif ($CGI->param("Verify")) {
>    Verify($CGI);
> }
> else {
>    displayLoginScreen($CGI);
> }
> sub displayLoginScreen {
>    [misc stuff]

IOW, even more important stuff removed.

>    foreach $state(@states) {    # I already have the state, of course
>       print "<option>$state";   # Still here for historical/testing
>    }
> 
>    [more stuff]

Probably irrelevant stuff here.

> }
> 
> Through the scope(?) of displayLoginScreen (main?) all of the state/county
> arrays/hashes are available, though note the @states syntax instead of
> @$states. (Why is this syntax working?) The states data is more persistent
> (I'll later figure out why if ever a pattern emerges), but Verify knows
> the county stuff only until the first validation error.

I'm not seeing all your declarations, nor how you handle parameters to
displayLoginScreen.

Further, I'd suggest using a framework (I use CGI::Application) rather
than coding CGI directly.  It can make a lot of this stuff make more
sense because it will greatly discourage global variables (which is
what you have).  Global scope is only evil because of scope issues. 
(If you know what you're doing, this can be used for great good, but
not usually.)

> Instead of making subsequent db fetches I want to send(?) any/all of these
> to any/all subsequent (inner?) subroutines that may need them. Is this
> possible and what might the referencing/dereferencing look like?

You can put your data into a hash, as an example, and pass around the
hash ref.  With CGI::Application (hereafter "C::A"), you would put the
data into your C::A object, and thus have access to it where you need
it via "$self".

> Verify calls other subroutines and then another HTML page. That page calls
> Register. Do I need to send references to Verify before sending them to
> the other subs?
> 
> You can see what I'm trying with Register. After many fanciful iterations

Actually, I'm not entirely sure.  Perhaps you could look at C::A (it's
on CPAN) and figure out how to reformulate your ideas into the neatly
partitioned framework that C::A provides.

> of code I'm still clueless. My wordiness is to encourage you to the same.
> Thanks to all.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to