I've been clumping along with procedural Perl for some time now and decided it's time to move into oop. So, I know how to create the package and how to reference the objects from my main program. What I can't seem to figure out is how do I call another subroutine (remember I'm coming from the land of procedural Perl) from within my package object. In very simple terms what I'm doing is:

1. There's a file called something.cgi. This has the appropriate require statements and calls a subroutine called getHeader($parm).

2. The getHeader subroutine lives in getheader.pl It is NOT a package.

3. There is a subroutine call dbSelect() that lives in dbselect.pl. This is NOT a package.

4. The getHeader subroutine creates an instance of the object Staff. Staff is in staff.pm. All is happy up to this point.

5. The getHeader subroutine calls the getFullName method in the Staff package. Here's the problem. getFullName has a call to dbSelect (the procedural subroutine that is stored in another file - dbselect.pl). At this point I get an error message telling me that the subroutine &Staff::dbSelect is not found!

I've tried every combination of use and require that seems logical and still no joy.

I would be most appreciative if someone could point out what I'm doing wrong. I think this should be simple but I'm just not getting it.

Thank you in advance!


In reply to Calling external subroutine from a package by badoosan

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.