Training, Open Source Programming Languages

This is page http://www.wellho.net/mouth/531_Pack ... -Perl.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
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))
Packages in packages in Perl

In perl, all your variables (except "my" ones, which we'll leave for another day) are arranged into packages, and by default that's a package called "main". So if you write about a scalar called $jeremy, that's really $main::jeremy and if you write about a named block of code called &mary, that's really &main::mary.

Why?

So that, as your programs grow, you can arrange all the variables and pieces of code into their own uniquely named modules. That then allows you to use the same name several times over without a conflict.

Good news - but it doesn't go far enough so far; what I've described only goes one level further and module files (for example) would all end up in a single massive "pancake" directory. So the :: notation can be nested, and package namespaces can be nested within package namespaces. As far as file organisation is concerned, you'll be working with a directory structure. This sort of thing is very much used on the CPAN, from where you can download modules such as Net::FTP - to be found once installed in a file called FTP.pm in the Net directory.

Here's an example program and some modules that show this in action.

$ perl pk2lev
tutor
designer
beauty therapist
$

And the pk2lev program:

use ellis::graham;
use ellis::lisa;
use whelan::lisa;
print ellis::graham::job();
print ellis::lisa::job();
print whelan::lisa::job();

The directory structure:

$ ls ellis whelan pk2lev
pk2lev

ellis:
graham.pm lisa.pm

whelan:
lisa.pm
$

And a sample module file:

$ cat ellis/lisa.pm

package ellis::lisa;
sub job {
return "designer\n";
}

1;
$
(written 2005-12-16, updated 2006-06-09)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P616 - Perl - FTP and Telnet Modules
  [975] Answering ALL the delegate's Perl questions - (2006-12-09)

P218 - Perl - More Objects
  [227] Bellringing and Programming and Objects and Perl - (2005-02-25)
  [246] When to bless a Perl variable - (2005-03-15)
  [588] Changing @INC - where Perl loads its modules - (2006-02-02)
  [592] NOT Gone phishing - (2006-02-05)
  [656] Think about your design even if you don't use full UML - (2006-03-24)
  [831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
  [930] -> , >= and => in Perl - (2006-11-18)
  [1217] What are factory and singleton classes? - (2007-06-04)
  [1320] Perl for Larger Projects - Object Oriented Perl - (2007-08-25)
  [1435] Object Oriented Programming in Perl - Course - (2007-11-18)
  [1664] Example of OO in Perl - (2008-06-03)
  [1665] Factory method example - Perl - (2008-06-04)
  [1819] Calling base class constructors - (2008-10-03)
  [1949] Nuclear Physics comes to our web site - (2008-12-17)
  [2427] Operator overloading - redefining addition and other Perl tricks - (2009-09-27)
  [2651] Calculation within objects - early, last minute, or cached? - (2010-02-26)
  [2717] The Multiple Inheritance Conundrum, interfaces and mixins - (2010-04-11)
  [2811] Igloos melt in the summer, but houses do not - (2010-06-15)
  [2876] Different perl examples - some corners I rarely explore - (2010-07-18)
  [2972] Some more advanced Perl examples from a recent course - (2010-09-27)
  [3097] Making Perl class definitions more conventional and shorter - (2010-12-20)
  [3098] Learning Object Orientation in Perl through bananas and perhaps Moose - (2010-12-21)
  [3377] What do I mean when I add things in Perl? - (2011-08-02)
  [3581] Perl - calls to methods that use => - what do they mean? - (2012-01-16)
  [3941] Building an object based on another object in Perl - (2012-12-03)
  [4096] Perl design patterns example - (2013-05-20)
  [4098] Using object orientation for non-physical objects - (2013-05-22)
  [4356] Object factories in C++, Python, PHP and Perl - (2014-12-19)
  [4366] Changing what operators do on objects - a comparison across different programming languages - (2014-12-26)

P209 - Subroutines in Perl
  [96] Variable Scope - (2004-10-22)
  [308] Call by name v call by value - (2005-05-11)
  [357] Where do Perl modules load from - (2005-06-24)
  [775] Do not duplicate your code - (2006-06-23)
  [969] Perl - $_ and @_ - (2006-12-07)
  [1163] A better alternative to cutting and pasting code - (2007-04-26)
  [1202] Returning multiple values from a function (Perl, PHP, Python) - (2007-05-24)
  [1782] Calling procs in Tcl and how it compares to Perl - (2008-09-02)
  [1784] Global - Tcl, PHP, Python - (2008-09-03)
  [1826] Perl - Subs, Chop v Chomp, => v , - (2008-10-08)
  [1850] Daisy the Cow and a Pint of Ginger Beer - (2008-10-21)
  [1860] Seven new intermediate Perl examples - (2008-10-30)
  [1921] Romeo and Julie - (2008-12-04)
  [2069] Efficient calls to subs in Perl - avoid duplication, gain speed - (2009-03-07)
  [2550] Do not copy and paste code - there are much better ways - (2009-12-26)
  [2833] Fresh Perl Teaching Examples - part 2 of 3 - (2010-06-27)
  [2929] Passing a variable number of parameters in to a function / method - (2010-08-20)
  [3066] Separating groups of variables into namespaces - (2010-11-24)
  [3574] Perl functions such as chop change their input parameters - (2012-01-10)
  [3833] Learning to use existing classes in Perl - (2012-08-10)


Back to
Perl course during the week, getting married at the weekend
Previous and next
or
Horse's mouth home
Forward to
Copyright - how much can I legally copy?
Some other Articles
MySQL permissions and privileges
Design - one name, one action
Bigger Box Campaign
Copyright - how much can I legally copy?
Packages in packages in Perl
Perl course during the week, getting married at the weekend
Halal in Melksham
Getting favicon to work - avoiding common pitfalls
Greater Western Franchise Awarded
Apache httpd - serving web documents from different directories
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/531_Pack ... -Perl.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb