CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in
Add ListingModify ListingTell A FriendLink to TPASubscribeNew ListingsCool ListingsTop RatedRandom Link
Newest Reviews
  • review
  • hagen software
  • NOT GPL!
  • Hagan Software
  • Wasted Time with ...
  • poor pre-sale sup...
  • no response
  • rating the offer
  • Good Stuff
  • Good idea but use...


  • Brochure Templates  
     
    Perl Archive : TLC : Programming : Perl : What are modules and do I need them?
    Guide Search entire directory 
     

    Date Published: 1999-08-01

    by D. Jasmine Merced
    TNS, Inc.

    What are Modules?

    Modules are chunks of perl code especially written to be shared by a variety of different perl applications. Performing specific functions -- both simple and complex -- the programmer may simply refer to an already developed module, saving time and effort.

    A perl program can utilize a module's functions by inserting a special line of code into the perl program. For example:

    use File::Find

    tells a perl program to use the "File::Find" module. After inserting the "use" line into a program, all of the module's functions become available to the perl program, expanding the functionality of the program very easily.

    Modules are written in a very specific format and typically end with a .pm extension.

    What do Modules do?

    Digging a little deeper, modules make perl an object oriented programming language. No need to cringe - object oriented programming, very simply put, means that you give data to a module, and the module, through sets of methods, performs various operations on the data. It then returns the result of those operations back to your perl program.

    There are countless modules available for your download and use. Used by perl programmers while developing applications, each module performs separate functions. For example, there is a module which looks up UPS rates (Business::UPS), that help you determine a gender from a name (Text::GenderFromName), or even work with polynomials (Math::Polynomial).

    There are countless ready-made modules, or, if you're ambitious and a fairly seasoned programmer, you can make your own modules, which you can use and reuse time and again.

    Do I need modules?

    If you're not a programmer, the only time you'll ever need to worry about modules is if you're downloading or purchasing a perl program that requires them. Because installing new modules onto your server often requires cooperation from your server administrator, most programmers don't force you to have the rather esoteric modules.

    What about if you want to buy a program that requires modules and don't know if the module is installed on your server? You could either ask your server administrator, or download a program such as Perl Diver to learn what modules are installed on your server.

    If you are a programmer, modules will save you countless hours of programming -- the work's already been done for you.

    Learning how to incorporate modules into your programs is beyond the scope of this article, but we recommend "Perl Modules" by Eric Foster-Johnson as a start. Though this book tries to teach by example, beware: You should be very comfortable with Perl before attempting to learn and use modules.

    Where can I find modules?

    Most of the most commonly used modules are already included in your distribution of perl. If you don't know what's on your server, and don't want to bug your system administrator, download a program such as PerlDiver to learn what modules are installed on your server.

    One of the best places to find modules is on CPAN (Comprehensive Perl Archive Network). There, you will find a browsable and searchable index of most of the modules available.

    We also incluse a listing of modules here on TPA. Though we don't list all of the modules on CPAN, we have some, as well as some that aren't in CPAN.

    D. Jasmine Merced is the President/CEO of Tintagel Net Solutions Group, Inc. and the administrator of The Perl Archive. She also serves as a Director of the World Organization of Webmasters.

     
     


    About The Perl ArchiveLink Validation ProcessSearch Tips
    Web Applications & Managed Hosting Powered by Gossamer Threads
    Visit our Mailing List Archives