in reply to Re: Error Message when I use Strict
in thread Error Message when I use Strict

What does that buy you over:
$SubroutName = 'test'; { no strict 'refs'; &$SubroutName; }
There's not much danger in using symbolic references - what "use strict 'refs'" does for you is prevent you from using symbolic references accidentally (which can be a problem), but that isn't the case here. The biggest danger lies probably in mistyping the value for $SubroutName, which will lead to a run-type error. But your dispatch table suffers from that as well. The use of a symbolic reference to call a sub hardly differs from your solution - except that the dispatch table isn't coded explicitly - you're using the stash as the dispatch table.

Replies are listed 'Best First'.
Re^3: Error Message when I use Strict
by Joost (Canon) on Jul 29, 2005 at 12:48 UTC
    The biggest danger lies probably in mistyping the value for $SubroutName, which will lead to a run-type error.

    No, the biggest danger lies in accidentally calling another subroutine that you don't plan on calling there. This becomes especially dangerous if the subname is passed from the user (like from a CGI form). Using a dispatch table makes the possible calls explicit, which is usually a good thing.

Re^3: Error Message when I use Strict
by holli (Abbot) on Jul 29, 2005 at 12:39 UTC
    But your dispatch table suffers from that as well.
    my $sub = $SubroutDispatch{$SubroutName} || sub {return};


    holli, /regexed monk/