in reply to Dynamic Method Calls

Uhh... why not just do something like:
$pack->$string if $pack->can($string);
That will pass strict 'refs' and will only call the function if the function can be called by that object.

------
/me wants to be the brightest bulb in the chandelier!

Vote paco for President!

Replies are listed 'Best First'.
Re (tilly) 2: Dynamic Method Calls
by tilly (Archbishop) on Aug 28, 2001 at 04:05 UTC
    It may be a matter of taste, but I would prefer to work in a system where a missing method generated a big fat visible error rather than silently not be called. Else I would predict that you will spend a lot of time chasing down little typos that cause method names to be just a tad off from what you intended...
Re: Re: Dynamic Method Calls
by runrig (Abbot) on Aug 28, 2001 at 01:33 UTC
    You can avoid one method lookup by going:
    if (my $code = $pack->can($string)) { &$code($pack, $string); );
      Method lookups get cached, so this isn't really needed. You're actually duplicating the caching efforts that the interpreter does for you.

      ------
      /me wants to be the brightest bulb in the chandelier!

      Vote paco for President!

Re: Re: Dynamic Method Calls
by ton (Friar) on Aug 28, 2001 at 01:27 UTC
    That worked perfectly. Thank you!
    -----
    Be bloody, bold, and resolute; laugh to scorn
    The power of man...