Use a hash dispatch. my %dispatcher = ( something => \&somethingElse, default => \&main, );
my $do = exists $dispatcher{ $q->param('do') } ? $dispatcher{ $q->param('do') } : $dispatcher{default}; $do->(); On Thu, Nov 09, 2006 at 05:56:33PM +0500, Sara wrote: > use strict; > use warnings; > use CGI; > > my $q = new CGI; > > my $do = $q->param('do') || 'main''; > > if ($do) { > &$do; > } > > sub main { > blah blah > } > ========================================= > Trying to call the subroutine main from variable $do but I am gettin' error: > Can't use string ("main") as a subroutine ref while "strict refs. > But somehow I don't want to remove the 'use Strict;' > > Any way out? > > Sara. > > -- Brad Lhotsky -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>