On Fri, 2005-03-11 at 14:54, Geoffrey G. Hankerson wrote:
> my $runmode = $query->param('page');
> my %rms = $self->run_modes();
> return $self->$rms{$runmode};
>
> gives me:
>
> syntax error at Supersite.pm line 684, near "$rms{"
> syntax error at Supersite.pm line 685, near "}"
>
> Where did I go wrong?
This should work:
my $runmode = $query->param('page');
my $subroutine = $self->run_modes->{$runmode};
if( !ref($subroutine) and $self->can($subroutine) ) {
$self->$subroutine();
}
elsif( ref($subroutine) eq 'CODE' ) {
&$subroutine($self);
}
else {
die "Can't find runmode: $runmode";
}
Wouldn't this be a good reason for CGI::Application to provide a formal
way of changing run modes. If it did it could also keep track of the
current run mode too. That would help the template name generation thing
that was brought up a while ago too.
Wouldn't it be nice if you could:
sub setup {
my $self =shift;
$self->run_modes(
runmode_1 => 'rm1',
runmode_1_process => 'rm1_process'
);
...
}
sub rm1_process {
my $self = shift;
# do something...
return $self->bounce("runmode_1");
}
sub rm1 {
my $self = shift;
return $self->current_runmode(); # outputs "runmode_1" even if
# the original HTTP request was
# to runmode_1_process
}
--
Tony Fraser
suppressed
Sybaspace Internet Solutions System Administrator
phone: (250) 246-5368 fax: (250) 246-5398
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.