in reply to Re^8: Function name in a variable, can't recall the concept (introspection with ->can )
in thread Function name in a variable, can't recall the concept

> could be as simple as \&{ $pkg . :: . $name }.

nope, this will autovivify a missing function glob $name and return a broken coderef.

try again.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

  • Comment on Re^9: Function name in a variable, can't recall the concept (introspection with ->can )
  • Download Code

Replies are listed 'Best First'.
Re^10: Function name in a variable, can't recall the concept (introspection with ->can )
by ikegami (Patriarch) on Apr 19, 2019 at 18:41 UTC

    You're missing the point. I'm not proposing a solution; I'm saying that yours is ludicrous. It makes absolutely no sense to use

    my $sub = @{ get_array_by_name($pkg, 'ISA') } ? get_sub_by_name($pkg, $name) : $pkg->can($name);

    instead of

    my $sub = get_sub_by_name($pkg, $name);

    The implementation of get_sub_by_name isn't relevant to that point.

      it's getting more and more ridiculous, I'm out.

      edit

      I replied to

      1) What's wrong with that? 2) You're missing the point. It doesn't matter what the code is, since + it's needed no matter what.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

        Yes, so I've been saying. Ludicrous, ridiculous, insane. These are synonyms.