Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Have I misunderstood the point of modules or just CPAN?

by perrin (Chancellor)
on Oct 24, 2008 at 15:53 UTC ( [id://719379]=note: print w/replies, xml ) Need Help??


in reply to Have I misunderstood the point of modules or just CPAN?

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.

  • Comment on Re: Have I misunderstood the point of modules or just CPAN?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://719379]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 04:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found