Here's 2 approaches that may get you what you want. 1 is to ref() the variable, and it will tell you something about the object.
my $what_is_it = ref($unidentified_object);
This may not return what you expect though, because most objects are of more than 1 type (they are whatever they were last bless()'ed as, and all of their parent class types). Someone else can certainly better explain exactly what ref() will return in various circumstances.
A probably better options is to use UNIVERSAL::isa(), which all classes inherit. isa() allows you to ask an object if its a certain type:
if ( $u_o->isa("blah" ) ) {
# do something
}
elsif ( $u_o->isa("something_else") ) {
# do something else
}
...
Depending on what you're trying to do, one or the other should probably do what you need.
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.