Perl already provides a built-in function to do this. It is the 'can' function which in contained in the UNIVERSAL package which every module inherits from. From the Advanced Perl Programming Book(O'Rielly):
Chapter 7.3 UNIVERSAL

All modules implicitly inherit from a built-in module
called UNIVERSAL and inherit the following three methods:

isa (package name)

     For example, Rectangle->isa('Shape') returns true if
the Rectangle module inherits (however indirectly) from
the Shape module. 
 
can (function name)
 
     Rectangle->can('draw') returns true if the Rectangle
or any of its base packages contain a function called draw. 
 
VERSION (need version)
 
      If you say, 

          package Bank;
          $VERSION = 5.1;
 
      and the user of this module says,
 
          use Bank 5.2;

      Perl automatically calls Bank->VERSION(5.2), which
can, for instance, make sure that all libraries required
for version 5.2 are loaded. The default VERSION method
provided by UNIVERSAL simply dies if the Bank's $VERSION
variable has a lower value than that needed by the user of
the module.
 
Because Perl allows a package to shamelessly trample on
other namespaces, some packages use the UNIVERSAL module
as a holding area for some global subroutines that they
wish to export to everyone. I recommend that you do not
use this "feature" yourself (or at least not in those that
you contribute to CPAN!).

In reply to RE: testFunction by johannz
in thread testFunction by nate

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.