in reply to Getting brackets right, checking for package subs

It would help us to help you better if you told us, exactly what errors you get in which case.

Personally, I always use the following snippet to handle symbolic references:

no strict 'refs'; defined &{ "$package\::$subname" }

but as I see that you're using a variable named $runmode, I get the feeling that you'd be better served by a simple dispatch table, especially as that brings you some more security:

my %runmodes = ( init => \&init, login => \&login, ... );

Replies are listed 'Best First'.
Re^2: Getting brackets right, checking for package subs
by cosmicperl (Chaplain) on Feb 19, 2009 at 13:27 UTC
    Ahh brilliant. Thanks. I've adapted this a little and ended up with:-
    defined &{ "${package}::$rmhash{$runmode}" }
    Which works with strict ref turned on.
    I would use a dispatch table, but that runmode hash is from CGI::Application.


    Lyle