If you add carp and your modules function(s) eg. Thing() to the @EXPORT global in your module, they will be exported into the namespace of anyone useing your module. However, this is not considered the "done thing" in most cases.

The alternative is to add them to the @EXPORT_OK global. Then, anyone useing your module must explicitly name them on their use yourmodule qw(yourfunc carp); line in order that they become part of their namespace. So, given a module defined as:

package Some::Really::Long; use Carp; use Exporter; @ISA=(Exporter); #@EXPORT=qw(Thing carp); # Method 1. @EXPORT_OK=qw(Thing carp); # Method 2. (preferred). $VERSION = 1.00; sub Thing{ return 'From Some::Really::Long::Thing()'; } 1;

And a main program defined as

#! perl -sw use strict; #use Some::Really::Long; # Method 1. use Some::Really::Long qw(Thing carp); # Method 2 (preferred). print Thing(),$/; carp "T'is a good day to die!\n";

Using either method, the program gives:

C:\test>test From Some::Really::Long::Thing() T'is a good day to die!
I am not sure whether propogating use'd methods this way is "the done thing". It seems that it would be easier to just have the child class use Carp; if it needs to, rather than trying to propogate it down? I'm sure you'll get other (and better) opinions on this.
Well It's better than the Abottoire, but Yorkshire!

In reply to Re: seamlessly use an extended class's use'd libs by BrowserUk
in thread seamlessly use an extended class's use'd libs by Anonymous Monk

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.