Exercises, examples and other material relating to training module P222. This topic is presented on public course Perl Extra
Programming in Perl is an art as well as a science. You can write code that looks beautiful and runs like a well-oiled machine, or you can write code that's quite otherwise. In this module, we'll look at how you can write code that's reliable, runs fast, and is easy to maintain.
|Articles and tips on this subject||updated|
|4611||Hungarian, Camel, Snake and Kebab - variable naming conventions|
In my program, I'm going to use a variable to hold the number of people (in a group or in a category) perhaps. What should I call that variable?
There are a whole lot of different conventions available to you - here are some I have used / come across
Camel case: numberOfPeople
A series of words, ...
|2657||Want to do a big batch edit? Nothing beats Perl!|
I still love Perl ...
Wanting to convert a file of lines like this:
into lines like this:
rp_153_track.jpg <img src=rp_153_track.jpg><br><br>
The code is as simple as:
print "$1 $_";
|2688||Security considerations in programming - what do we teach?|
Many moons ago, I wrote and presented a security course - and ever since that time I have been acutely aware of the need to consider security in every aspect of system design, program writing and maintenance. And these days - with many of our programs "exposed" to people to run from remote places via ...
|2399||Firefighting with Perl|
If the building is blazing, you'll go right ahead and put the fire out with the extinguisher. Hopefully you'll have been trained to use the right sort of extinguisher on the right fire, but you won't leave the fire to blaze just because the "date last serviced" record has become smudged and you don't ...
|1181||Good Programming practise - where to initialise variables|
It's a good idea to initialise your variables directly before you use them for the first time if you're going to use them as accumulators.
By accumulator I mean that you're going to write assignments such as:
$n += 4; # Perl
incr notepad; # Tcl
lappend flcodes [lindex ...
|743||How to debug a Perl program|
Have you every written a Perl program that doesn't perform as you would wish? Yes, everyone who's written a Perl program has done that. Once any syntax errors have been corrected, you run your program for the first time and you check - VERY carefully - the results. Any errors, and the patterns of errors, ...
Examples from our training material
|control|| regular expression efficiency demo - control|
|try1|| regular expression efficiency demo - start with literal|
|try2|| regular expression efficiency demo - start with anchor|
|try3|| regular expression efficiency demo - remove use of $&|
|try4|| regular expression efficiency demo - process line by line|
|try5|| regular expression efficiency demo - read into list|
|try6|| regular expression efficiency demo - via foreach|
|try7|| regular expression efficiency demo - index rather than regex|
|trybench|| regular expression efficiency demo - testing with benchmark module|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
Perl as a language for style and efficiency.
Planning your programming.
Programs written quickly?.
Programs that are easily maintained and altered to new requirements?.
Programs that require minimal memory?.
Programs that work effectively for the user?.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
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 700 books on the subjects on which we teach.
These books are available for reference at our training centre.