Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Module or Library File

Posted by TedH (TedH), 30 April 2008
Hi. One of the things I use often are files containing sub routines that are used in a variety of scripts. Each script requiring a reusable sub simple calls the sub from the "required" lib file. I usually name the file as a filename.lib.

Another way of reusing code is a Perl Module. My question is: Which is better?

Do modules behave differently than library files?

Like, are they better when a lot of different scripts might use them at near the same time?

Or is there really not much difference at all?

I realize I will have to look at different modules to see how stuff is written in the module and then used in a script - thought I'd say that to save you telling me I've also downloaded a few tutorials (but they tend to go around the world to cross the road on some points).

Cheers - Ted

Posted by admin (Graham Ellis), 1 May 2008
In essense, a use is a require that's run at the time the code is being compiled rather than as it is being run. (i.e. it's a require in a BEGIN block)

This means that you can use require code to optionally load things, but use code comes in at compile time, even if it's in the middle of a conditiional block of some sort.   And because use comes in at compile time, it can be used to define bare words  and pragmata that effect the rest of the compile.

Hopefully haven't given you a complete world tour there, Ted!

Posted by TedH (TedH), 1 May 2008
Hi Graham;
I think I've got it.

What I have is an admin script where some code elements are repeated at different points in different sub-routines. I thought that if I used a library file with the repeated code in (as individual subs) and simply called the subs as needed, I could cut things down size wise. It does work that way (I haven't broken it yet so it seems to be okay). I was concerned about its overall efficiency and figured if I make a localized module it might help.

Hopefully haven't given you a complete world tour there, Ted! Nah, just a pleasant stroll through the wood to the stuff that was already on the other side of the trees anyways.

Cheers - Ted

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho