Sure. If you've got a reference you can check its type with the SvTYPE macro. For example (untested):
if (SvROK(sv) && SvTYPE(sv) == SVt_PVCV)
warn("sv is a code reference (CV) alright.");
As for your second question, you can check that an sv is a reference to an object of (or derived from) a given class using sv_derived_from() (untested all the way):
if (SvROK(sv) && sv_derived_from(sv, "Foo"))
warn("sv isa Foo");
And to check that a method is valid for a given class you can do something like (really untested):
if (gv_fetchmethod(gv_stashpv("Foo", 0), "Foo::bar"))
warn("succeeded in finding Foo::bar");
Now, I doubt I answered your all your questions, but you weren't exactly clear about what you're trying to do. Maybe you can explain in more detail?
-sam
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.