Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Here's a quick, off-the-cuff explanation of exporting/importing:

First, exporting and importing are the same thing; like emigrating/immigrating, it just depends which side you're looking from. :)

Exporting/importing is simply the process of making a link from a symbol (or part of a symbol) in one package to a symbol in another package, so that the symbol can be accessed from either package. For example, if you import CPAN's install method, then CPAN exports it (by using Exporter) with this assignment: (*{"${callpkg}::$sym"} = \&{"${pkg}::$sym"}. That actually makes an assignment to the symbol table for the calling package. Assuming $callpkg is main, now main::install and CPAN::install refer to the same subroutine. The \& on the RHS of the assignment means that only the subroutine part of the CPAN::install symbol was duplicated; the scalar, array, hash, and other parts were not. Exporter does separate assignments for each data type, so that only what was asked for is imported.

The reason for exporting/importing is simply to make accessing symbols in other packages easier, by bringing them into your package. Someone using the functional interface to CGI, for example, would have to write out CGI::header(), CGI::start_html(), CGI::param(), etc., for every function, if they couldn't import the methods.


In reply to Re: Exporting by chipmunk
in thread Module Submission for CPAN by tedv

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2023-02-07 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?