Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi,

Glad to hear you're playing with modules and checking out CPAN.

Most of CPAN is not written in C, but some of the most useful modules on it do have some C code. A good example would be DBI. Usually when modules use C it's either because the job requires the performance of C or because a handy C library already existed and the author wanted to make it available to perl coders. But the vast majority of CPAN has no C code. If that doesn't match your experience, maybe you'd like to tell us what modules you've been looking at?

Your general question seems to be why the modules on CPAN are more complex. I'm guessing that your modules may not have separate package names and just import all of their subs into the main program when used. They don't have Makefile.PL installers like CPAN modules do. And they don't track dependencies between themselves.

The answer has to do with scale. For a very small amount of code like you have, the complexity can be managed without help. When you start to have large projects with thousands of lines of code, you need the things CPAN-style modules offer to keep it all straight. The standard installation and dependency tracking makes it possible for the whole perl community to use and contribute to CPAN.

If you're wondering which practices you should try to emulate in your own code, you might start with package names. Small modules that you only use locally don't usually need to have installers or dependency tracking.

BTW, there are tools for building an executable with all dependencies if you want to send a complex thing to friend on Windows without making them install modules from CPAN.

I recommend you check out this book, Writiing Perl Modules for CPAN, by samtregar. It's a free download and will answer your questions more fully.


In reply to Re: Have I misunderstood the point of modules or just CPAN? by perrin
in thread Have I misunderstood the point of modules or just CPAN? by RAS230

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 examining the Monastery: (6)
As of 2024-03-28 23:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found