Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
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

Learning to program in PerlThere'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

Learning Perl at Well HouseBefore 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

Perl training at Well HouseInput, 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

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

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

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

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

P206 - Perl - More Loops and Conditionals
  [3914] While, for, foreach or something else to loop. - (2012-11-06)
  [3619] Ruby v Perl - a comparison example - (2012-02-21)
  [3200] How a for loop works Java, Perl and other languages - (2011-03-12)
  [2972] Some more advanced Perl examples from a recent course - (2010-09-27)
  [2967] Multiway branches in Perl - the given and when syntax - (2010-09-22)
  [2892] Alternative loops and conditionals in Ruby and Perl - (2010-07-28)
  [2824] A pint of Black Rat, and a lazy barman - (2010-06-25)
  [2817] Setting a safety net or fallback value in Perl - (2010-06-19)
  [2815] switch and case, or given and when in Perl - (2010-06-17)
  [1825] Question Mark - Colon operator (Perl and PHP) - (2008-10-08)
  [1582] Ruby, C, Java and more - getting out of loops - (2008-03-19)
  [1220] for loop - how it works (Perl, PHP, Java, C, etc) - (2007-06-06)
  [962] Breaking a loop - Ruby and other languages - (2006-12-03)
  [657] The ternary operator in Python - (2006-03-25)
  [299] What - no switch or case statement? - (2005-05-03)
  [138] Perl - redo and last without a loop - (2004-12-02)


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., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2832_Are ... -you-.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat