Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Cool thread. My latest revelation was about Exporter. I've written some modules that don't need it at all, and I've written some that do need it, in order for a caller script to just use a given function. But it wasn't till a few days ago that I finally learned (or figured out / absorbed / understood) what the difference is between needing Exporter vs. not needing it:

The ones that didn't need Exporter were OO-style; the "ModuleName->new()" or "new ModuleName" method never needs to be explicitly exported, and the returned object reference provides the caller with simple and direct access to the module's methods.

The modules that aren't OO-style don't supply that sort of handy object reference, so Exporter is needed in order for the module's function names to be accessible to the caller without the clunky "ModuleName::" prefix.

At least, that's how I've come to understand it (finally). I must have known some part of this before (when writing those OO-style modules), but it turns out I don't write modules all that often, and I actually did scratch my head a bit recently when writing a simple "functions-only" module, trying to recall what incantation to use involving Exporter, and seeing that some of my older modules didn't use it at all (yet these never needed the "ModuleName::" syntax when being used).

I attribute my surprise to my habitually "procedural" mindset, which Perl supports so effectively.


In reply to Re: What I Most Recently Learned in Perl, But Should Have Already Known by graff
in thread What I Most Recently Learned in Perl, But Should Have Already Known by liverpole

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?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found