Home Accessibility Courses Twitter The Mouth Facebook 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))
Are you learning Perl? Some more examples for you!

One of the things that you'll get on a Well House Consultants course is new code written by the tutor in front of your very eyes. We do that because:

• you need to learn not only how code works, but also the though code process behind the code - not only how it is written in a ceratyin way but why.

• you need to be able to ask questions as we go along, and not just when presented with a final answer.

• you gain far more from your course if we use your data / tailor the course to your needs as we go along - if we keep it relevant.

There's a downside as far as we're concerned, though - it means that we need to have every single class taught by someone who knows Perl REALLY well - we can't put in a "read the book to the class" guy or gal if we're a bit busy one week. But that downside to us is the most tremendous upside to you - you get someone who REALLY know Perl well, and that's on every course.

Often, the examples aren't especially tidy when we finish the course; they may be emailed to the delegates if requested, or they may be tossed as having fulfilled their purpose. However, I have spent a great deal of this weekend documenting the Perl examples I wrote to a higher standard, so that they're suitable for publication and reuse.

This post is the first of three that will introduce the new examples, subject by subject. Please follow links to the source code where it's of interest, as you'll find further documentation - sometimes line by line where it's appropriate.

And if you would like to learn Perl from us ... please look at our Perl training course options. Or send me an email to discuss your own particular needs.

P201- Perl Introduction

There's a lot to Perl - and early on in learning the language, delegates need some overview of where they're headed - a morale boosing view to say "look - with a few simple elements, you'll be amazed what you can do".

So at the end of the first day of training, I write some fresh examples using what I've taught in that first day, with a few extras along the "we'll see this in the next day orr two" lines.

Here are those examples from last week ...

Counting records of different types from a large log file - [source]

An extended version of that demonstration, which analyses all the possible record types - [source]

And another example - this time with sorted output [source]

And finally, by special request of two of the delegates, output in XML - [source]





P202 - Perl Fundamentals

Before you start coding in ANY language, you should think ahead and plan what you're doing - and a good way to do this is to write your comments first. I did this during the recent Perl course, with programs to calculate body/mass index.

First sample program - [sources]

I then went on to add conditionals to the code - not only does the second program tell you your BMI, but it tells you what it means (please consult your doctor and don't trust us - it's just a simple general case on the Perl course and we cannot take responsibility, etc ...)

Second sample program - [here]

The final example adds a loop - you enter your height and weight, and it produces a whole table to show what happens to your BMI as you loose and gain weight (there's an assumption that your height won't change!)

Third sample program - [here]





P204 - Conditionals and Loops in Perl

Input, calculations, output. Conditionals and loops. Once you've got those basics, you can write some useful programs.




P205 - Initial String Handling in Perl

Does 3 equal 3.0? You may say "yes" and you may say "no" - both answers are sort of correct - the real question is "what to you mean by equals".

Perl has three different ways of comparing - and all are illustrated in a sample program - [here] - which I wrote during the course last week.

To add further complexity, but to make Perl much easier to use once you understand it, Perl 5.10, Perl 5.12 and Perl 6 onwards have an extra operator - the intelligent match operator - which chooses between the three well established comparisons, and others beside, if you use ~~. See [here] for more details.




What's the difference between single and double quotes? What are q and qq? What is a "here document". There's an explantion in the comments - and a sample in the source - [here]


P206 More Perl Loops and Conditionals

Perl has a large number of ways of doing anything - and nowhere will you see that more than with loops and conditionals - a program showing some of the more esoteric examples can be found [here] - an excersize which I asked delegates to do (then did myself) to make use of a wide range of alternatives.

Some of the extra ways - though are VERY useful in use, such as the ? : operator which is a short form of if and else. I wrote an example, and it's documented [here].

Pictures - delegates on last week's course. And it's not ALL study - on the evenings, I took a stroll in the countryside near to us, as I often do. And I was delighted to be accompanied by several delegates and to help promote our motto - "Come as a student, leave as a friend"


To be continued ....

Three part article ... this is part 1. Jump to part [2] [3]

(written 2010-06-27)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P206 - Perl - More Loops and Conditionals
  [138] Perl - redo and last without a loop - (2004-12-02)
  [299] What - no switch or case statement? - (2005-05-03)
  [657] The ternary operator in Python - (2006-03-25)
  [962] Breaking a loop - Ruby and other languages - (2006-12-03)
  [1191] Smart English Output - via PHP and Perl ? : operator - (2007-05-18)
  [1220] for loop - how it works (Perl, PHP, Java, C, etc) - (2007-06-06)
  [1582] Ruby, C, Java and more - getting out of loops - (2008-03-19)
  [1696] Saying NOT in Perl, PHP, Python, Lua ... - (2008-07-04)
  [1825] Question Mark - Colon operator (Perl and PHP) - (2008-10-08)
  [2711] For loop - checked once, or evety time? Ruby v Perl comparison and contrast - (2010-04-07)
  [2815] switch and case, or given and when in Perl - (2010-06-17)
  [2817] Setting a safety net or fallback value in Perl - (2010-06-19)
  [2824] A pint of Black Rat, and a lazy barman - (2010-06-25)
  [2892] Alternative loops and conditionals in Ruby and Perl - (2010-07-28)
  [2967] Multiway branches in Perl - the given and when syntax - (2010-09-22)
  [2972] Some more advanced Perl examples from a recent course - (2010-09-27)
  [3200] How a for loop works Java, Perl and other languages - (2011-03-12)
  [3398] Perl - making best use of the flexibility, but also using good coding standards - (2011-08-19)
  [3619] Ruby v Perl - a comparison example - (2012-02-21)
  [3914] While, for, foreach or something else to loop. - (2012-11-06)

P205 - Perl - Initial String Handling
  [31] Here documents - (2004-08-28)
  [254] x operator in Perl - (2005-03-22)
  [324] The backtick operator in Python and Perl - (2005-05-25)
  [970] String duplication - x in Perl, * in Python and Ruby - (2006-12-07)
  [987] Ruby v Perl - interpollating variables - (2006-12-15)
  [1195] Regular Express Primer - (2007-05-20)
  [1608] Underlining in Perl and Python - the x and * operator in use - (2008-04-12)
  [1849] String matching in Perl with Regular Expressions - (2008-10-20)
  [1860] Seven new intermediate Perl examples - (2008-10-30)
  [2798] Perl - skip the classics and use regular expressions - (2010-06-08)
  [2816] Intelligent Matching in Perl - (2010-06-18)
  [2963] Removing the new line with chop or chomp in Perl - what is the difference? - (2010-09-21)
  [3005] Lots of ways of doing it in Perl - printing out answers - (2010-10-19)
  [3411] Single and double quotes strings in Perl - what is the difference? - (2011-08-30)
  [3547] Using Perl to generate multiple reports from a HUGE file, efficiently - (2011-12-09)
  [3548] Dark mornings, dog update, and Python and Lua courses before Christmas - (2011-12-10)
  [3770] Sample answers to training course exercises - available on our web site - (2012-06-21)

P204 - Perl - Conditionals and Loops
  [353] Wimbledon Neck - (2005-06-20)
  [930] -> , >= and => in Perl - (2006-11-18)
  [1468] Lexical v Arithemetic testing, Bash and Perl - (2007-12-11)
  [1477] Decisions - small ones, or big ones? - (2007-12-18)
  [1607] Learning to program in Perl - (2008-04-11)
  [1727] Equality and looks like tests - Perl - (2008-07-29)
  [2351] Ternary operators alternatives - Perl and Lua lazy operators - (2009-08-12)
  [2550] Do not copy and paste code - there are much better ways - (2009-12-26)
  [3004] Increment operators for counting - Perl, PHP, C and others - (2010-10-18)
  [3397] Does a for loop evaluate its end condition once, or on every iteration? - (2011-08-18)
  [3895] Flowchart to program - learning to program with Well House - (2012-10-14)
  [4031] Showing what programming errors look like - web site pitfall - (2013-03-06)
  [4322] Learning to Program - the conditional statement (if) - (2014-11-21)
  [4323] Learning to program - Loop statements such as while - (2014-11-22)

P202 - Perl Fundamentals
  [184] MTBF of coffee machines - (2005-01-20)
  [748] Getting rid of variables after you have finished with them - (2006-06-06)
  [1312] Some one line Perl tips and techniques - (2007-08-21)
  [1448] Question on division (Java) - Also Perl, PHP, Python ... - (2007-11-28)
  [1726] Hot Courses - Perl - (2008-07-28)
  [1826] Perl - Subs, Chop v Chomp, => v , - (2008-10-08)
  [1946] Variable Types in Perl - (2008-12-15)
  [2442] Variable storage - Perl, Tcl and Python compared - (2009-10-08)
  [2876] Different perl examples - some corners I rarely explore - (2010-07-18)
  [3059] Object Orientation in an hour and other Perl Lectures - (2010-11-18)
  [3102] AND and OR operators - what is the difference between logical and bitwise varieties? - (2010-12-24)
  [3278] Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. - (2011-05-05)
  [3329] Perl from basics - (2011-06-20)
  [3542] What order are operations performed in, in a Perl expression? - (2011-12-07)
  [3574] Perl functions such as chop change their input parameters - (2012-01-10)
  [3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
  [4324] Learning to program - variables and constants - (2014-11-22)

P201 - Perl - Introduction
  [25] Release numbers - (2004-08-23)
  [317] Programming languages - a comparison - (2005-05-20)
  [382] Central London Courses - Perl, PHP, Python, Tcl, MySQL - (2005-07-18)
  [577] Learning to program in Perl or PHP - (2006-01-26)
  [594] Twice is a co-incidence and three times is a pattern - (2006-02-07)
  [604] Perl - multiprocess applications - (2006-02-13)
  [629] Choosing the right language - (2006-03-01)
  [691] Testing you Perl / PHP / MySQL / Tcl knowledge - (2006-04-19)
  [743] How to debug a Perl program - (2006-06-04)
  [846] Is Perl being replaced by PHP and Python? - (2006-08-27)
  [924] The LAMP Cookbook - Linux, Apache, MySQL, PHP / Perl - (2006-11-13)
  [1717] Q - Should I use Perl or Python? - (2008-07-23)
  [1753] Perl v PHP, choosing the right language - (2008-08-14)
  [1852] Perl and Blackberries - (2008-10-23)
  [2070] Converting to Perl - the sort of programs you will write - (2009-03-08)
  [2812] What is Perl? - (2010-06-15)


Back to
Recording (a macro) in vi
Previous and next
or
Horse's mouth home
Forward to
Fresh Perl Teaching Examples - part 2 of 3
Some other Articles
Perl - the duplicate key problem explained, and solutions offered
A course is more than just a chap giving a lecture
Teaching examples in Perl - third and final part
Fresh Perl Teaching Examples - part 2 of 3
Are you learning Perl? Some more examples for you!
Recording (a macro) in vi
Poulshot Village Fete
Dauncey Gardens, Melksham
Sharing our programs - easy. Sharing our data - harder.
Melksham - a gem in Wiltshire
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).

You can Add a comment or ranking to this page

© 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/2832_Are ... -you-.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb