Training, Open Source computer languages

PerlPythonMySQLTclRubyC & C++LuaJavaTomcatPHPhttpdLinux

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
You are currently on our new server (weekend of 19th/20th July). See here.

Tips and short articles on this subject
Returning multiple values from a function (Perl, PHP, Python)
A better alternative to cutting and pasting code
Perl - $_ and @_
Do not duplicate your code
Changing @INC - where Perl loads its modules
Packages in packages in Perl
Where do Perl modules load from
Call by name v call by value
Variable Scope
Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Subroutines in Perl - module P209
As your code grows in size, you'll want to divide it down into manageable chunks for ease of maintenance, and so that you can reuse logic at different points in the same application, or even from different applications. Perl's way of naming a block of code is a "subroutine".

This topic is presented on public courses Perl Programming, Perl bootcamp

Examples from our training material
bridges.pm   subroutines called up from example applications
courses.pl   Sample (test) program to try out a diary
cov2.pm   Coverage as a class. Allows multiple parallel coverage sets!
coverage.pm   Routines to combine integer ranges to provide overall coverage information
covertest   Sample application - coverage test given ranges of integers
ct2   Coverage test - application using coverage objects
diaryev.pm   Sample class for courses.pl demo
email.pm   email class of objects - a very simple class
globvar   demonstration that variables default to global
mailfilter.pm   package to encapsulate information - NOT really objects.
mailister2   including package name in package methods
maillister   using a module to retain information
mc   Email analysis via a package
mc2   using email objects
mf2.pm   package of subroutines for mailfilter2
ms2   calling subroutines in a different file
mysub   calling a subroutine in the same file
myvar   Use of my to reduce variable persistance and scope
subgetnum   Sample use of subroutines - returned parameters
subgnrange   Passing parameters in and out of subroutines
substamp   Sample use of subroutines
valread.pm   standard subroutines to include in several programs
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from http://www.training-notes.co.uk.
Topics covered in this module
What are subroutines and why?.
The limitations of "single block code".
First use of subroutines.
Structured programming.
Object oriented programming.
Calling a subroutine.
Passing values out of subroutines.
Passing values in to subroutines.
Writing your own subroutine.
Passing parameters in.
Returning values.
Writing subroutines in a separate file.
Scope.
Global Scope.
my variables.
A test program:.
packages.
Calling objects.
Writing a class - an introduction.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 600 books on the subjects on which we teach. These books are available for reference at our training centre. Also available is the Opentalk Forum for discussion of technical questions.


© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 0800 043 8225 or 01225 708225 • FAX: 0845 8382 405 or 01225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho