Pardon my ignorance of Perl and CGI::App 

I have received 3 distinct suggestions none of which have worked so far.

To review, I know the runmodes hash key but not the value. So in one
case the key might be "mode2" and the value "create_category_form".  So
what I need to do is look up the value based on the key.  I can get the
key like so:
my $runmode = $query->param('page');

1.Steve Comrie suggests:
return $self->$runmode(); should work just fine.

Except it didn't work just fine. This gives me this error:
Error executing run mode 'mode32': Can't locate object method "mode2"
via package "Supersite" at Supersite.pm line 693.


2. Micael Peters suggests:
my $runmode = $query->param('page');
my %rms = $self->run_modes();
return $self->$rms{$runmode};

This returns this error:
syntax error at Supersite.pm line 694, near "$rms{"
syntax error at Supersite.pm line 696, near "}"


 Dan Horne suggests this:
my $runmode = $query->param('page');
my %rms = $self->run_modes();
return $rms{$runmode};

This is closer and returns the name of the subroutine as text to the
browser



3. Tony Frazier suggests
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";
    }

Throows this error:
Error executing run mode 'mode32': Can't use string ("21/32") as a HASH
ref while "strict refs" in use at Supersite.pm line 683
Line 683 is my $subroutine = $self->run_modes->{$runmode};


I thought all I would have to do is:
return $self->run_modes->{$runmode};


Any further advice is appreciated. THank you 

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to