On Dec 4, 2003, at 12:21 PM, Jonathan Mangin wrote: [..]
This is a pretty old book and I'm wondering if there's a
newer, better way? I wish to be able to achieve what would
be the results of this (if it were possible):

if ($CGI->param("Screen3")) {
   showmeScreen3($CGI, %widgets);
}
...

but, of course, %widgets doesn't exist at compile time.
Something I read in perlreftut made me think I might be
able to use a reference here. Possible?

Alternatively, is there syntax that allows passing a hash
using a hidden input variable? i.e.:

<input type=hidden name=widgets value="%widgets">
[..]

I think you might want to re-think your basic 'interface'
and then you might find that 'dispatchers' are your friend.

First the Interface, then the dispatcher.

Let's put in something like

<input type="hidden" name="screen" value="Screen3">

Then you could go with a dispatcher of the form

        my %process = (
                Screen1 => \&showScreen1,
                Screen2 => \&showScreen2,
                Screen3 => \&showScreen3,
        );

...

my $screen = $CGI->param("screen")

        if ( exists($process{$screen}))
        {
                $process{$screen}($CGI);
        }else{
                process_broken_cgi($CGI);
        }
                
This way only the 'widgets' that need to be 'hidden'
are actually shipped out in the html... This way you
can also 'grow' your Dispatcher as you need to,
and add functionality as required...

ciao
drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to