Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Is there a Perl API (XS) for ->can ?

by NERDVANA (Priest)
on Oct 08, 2021 at 06:17 UTC ( [id://11137334]=perlquestion: print w/replies, xml ) Need Help??

NERDVANA has asked for the wisdom of the Perl Monks concerning the following question:

Hi, in one of my XS modules I want to do the equivalent of PKG->can($method). It feels like this would be in the perl api, but keyword searching for 'can' is somewhat futile. Is there any way to run this operation more efficiently than literally building a call to method 'can'?

Replies are listed 'Best First'.
Re: Is there a Perl API (XS) for ->can ?
by Anonymous Monk on Oct 08, 2021 at 09:06 UTC
      Thanks! gv_fetchmeth was what I was looking for.
Re: Is there a Perl API (XS) for ->can ?
by LanX (Saint) on Oct 08, 2021 at 08:39 UTC
    FWIW: My idea was that a direct call is more efficient.

    Hence the XS equivalent to

    $sub = UNIVERSAL::can($obj, "print");

    But UNIVERSAL says

    > # but never do this!

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11137334]
Approved by Fletch
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2025-07-14 13:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.