Exercises, examples and other material relating to training module P303. This topic is presented on public course Perl for Larger Projects
If you're going to be using Perl in depth every day, this module covers some golden nuggets and extra syntaxes that you might have been looking for. There's a rule of thumb with Perl Ð "If you're finding something more difficult than you expected, there's probably an easier way".
|Articles and tips on this subject||updated|
|3159||Returning multiple values from a function call in various languages - a comparison|
I've always thought it a bit odd that you call a function with any number of parameters, and yet it returns a single value; in Java, C or C++ you declare a return type (void if there is not to be anything returned) and you are then constrained by that specification. There are, of course, other ways ...
|2876||Different perl examples - some corners I rarely explore|
The private Perl course that I ran on Wednesday through Friday of last week was a little out of the ordinary as we were concentrating far more that usual on a wide variety of practices that may be found - either in legacy code or advanced recent code. Great fun for me, and plenty of new examples.
|3012||Exception handling in Perl - using eval|
Exception handling is the trapping of nonstandard results from blocks of code or functions - for example, if I draw a card from a pack and ask you "what suite is this?" you'll usually be able to tell me "it's a heart" or "it's a club" ... but if I had drawn a joker, there would have been no appropriate ...
|2877||Further more advanced Perl examples|
I've uploaded a further batch of new examples (that makes around 40 in total!) from the private Perl course that I ran from Wednesday through Saturday last week - many of them adding a new twist on to previous examples. If you read a comment below and thing "that's what I'm looking for an example of", ...
|2219||Configuring httpd, or Tomcat, to run CGI scripts in Perl|
Here's a Perl / CGI script - a "Common Gateway Interface" program that I want to run on my web server, and access via my browser. What server to I need to run it on, and how do I set that server up?
print ("Content-type: text/html\n\n");
$now = localtime();
print "<h1>It ...
|2427||Operator overloading - redefining addition and other Perl tricks|
What does addition actually mean? It means different things depending on what you're adding together, and in Perl you can redefine additions - and other operators - on objects of types which you define. This is known as operator overloading, and there's a complete code example here.
So ... how do ...
Examples from our training material
|asp|| Command line options to add implicit read loop and split|
|cmc.pm|| Defining a subroutine prototype|
|dob|| uses of "do"|
|evx|| try and catch simulation via eval|
|go1|| The goto statement ... if you must ...|
|go2|| goto based on a value - a sort of switch|
|go4|| Goto an array of possibilities|
|goflavours|| goto, and jumping with last|
|gogo|| Goto based on string|
|hoco|| the continue block|
|mudemo|| running an operating system command |
|mudemo2|| Testing to see if a variable is tainted|
|owncheck|| Use of caller and wantarray|
|pex|| Exception Handing in Perl|
|pmg|| magic goto|
|protodemo|| subroutine prototype|
|spt3|| A subroutine prototype defined too late|
|spt4|| A subroutine prototype defined in time|
|sptest1|| Using a prototyped method correctly|
|sptest2|| Using a prototyped method incorrectly|
|sudemo|| Operation that will fail if run tainted|
|waw|| warnings, caller, wantarray, ref, $#_|
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
Checking calling sequences.
Where am I?.
Which file? Which line of that file?.
The unconditional goto.
The "computed" goto.
goto a subroutine.
Do and continue.
Command line options.
How does tainting work?.
How do I tell if a scalar is tainted?.
Other special variables.
Special file handles.
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.