You can access anything you want by fully qualifying it with a package name; e.g. in Blah:

use Foobar; sub doSomething { Foobar::some_method(); }
The danger here is that Foobar is acting like an instance method and wants an object reference as its first argument. You don't have one just calling it as shown above. To do that you need to create a Foobar object first, in which case access is as you'd expect:
my $f = Foobar->new(); $f->some_method();

Make sure you understand the difference between class and instance methods before digging in too far here. Perl also lets you write methods that do either if you want, as much as that pisses off some OO purists:

sub class_or_instance { my $invocant = shift; if (ref($invocant)) { # got an instance (i.e., a "self" reference) } else { # got a class name (hopefully anyway ... 8-) } } ... Foobar->class_or_instance() # passes class name "Foobar" in as @_[0] my $f = Foobar->new(); $f->class_or_instance(); # passes object $f in as @_[0]
I say "hopefully" in the comment because you could trip yourself up by doing this:
Foobar::class_or_instance('blech');
Tighter error checking is left as an exercise for the reader. 8-)

In reply to Re: accessing subs/methods from the module by steves
in thread accessing subs/methods from the module by shrubbery

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.