Sometimes, examples written during a course are throw-aways ... but at other times they become a useful addition to our resources. On a private
private Perl course that I was running yesterday, and continues today and Monday, I found myself writing a useful piece that shows examples of lots of ways of doing virtually the same thing in Perl - and remember the Perl manta - "There's more than one way of doing it" is the headline at the top of
"Perl Programming" - the book that's also known as "the camel book" and "The Perl bible".
What does the new example (which you can show
[here] in a separate frame) cover?
1. 2 different ways of removing the new line from the end of input
2. 6 different ways of formatting a string for output
3. 12 different ways of writing a condtional (optional) statement
4. 8 different ways of writing code that repeats in a loop
In some ways, variety is good. In other ways ... there are just too many ways of doing things; if code is written by someone who "delights" in using many of them, the people who maintain the code may be given a somewhat tougher task. So I'm a strong advocate of teaching delegates to be
aware of the options for when they come to maintain code, but to be
selective in what they use when it comes to writing new code.
Within different environments and organisations, stanadards (be they formal or infoaml) should be set for Perl coding to ensure that it
can be maintained. But there are some things that date back to the early days of Perl such as
goto and
redo for loops which should really not be written into new code within any standard.
Next
public Perl course ... starts 19th September. There's another one from 5th December, and dates for next year will be on the website by the end of this month. There's also an
advanced Perl course in November ...
(written 2011-08-19)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P711 - An Introduction to Standards in Perl [242] Satisfaction of training - (2005-03-11)
[668] Python - block insets help with documentation - (2006-04-04)
[743] How to debug a Perl program - (2006-06-04)
[945] Code quality counts - (2006-11-26)
[965] KISS - one action per statement please - Perl - (2006-12-05)
[1047] Maintainable code - some positive advice - (2007-01-21)
[1221] Bathtubs and pecking birds - (2007-06-07)
[1345] Perl and Shell coding standards / costs of an IT project - (2007-09-11)
[1395] Dont just convert to Perl - re-engineer! - (2007-10-18)
[1555] Advanced Python, Perl, PHP and Tcl training courses / classes - (2008-02-25)
[1728] A short Perl example - (2008-07-30)
[1853] Well structured coding in Perl - (2008-10-24)
[1863] About dieing and exiting in Perl - (2008-11-01)
[2375] Designing your data structures for a robust Perl application - (2009-08-25)
[2688] Security considerations in programming - what do we teach? - (2010-03-22)
[2875] A long day in Melksham ... - (2010-07-17)
[4326] Learning to program - comments, documentation and test code - (2014-11-22)
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)
[2832] Are you learning Perl? Some more examples for you! - (2010-06-27)
[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)
[3619] Ruby v Perl - a comparison example - (2012-02-21)
[3914] While, for, foreach or something else to loop. - (2012-11-06)
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)
Some other Articles
That spec is a kingfisher ...Open Source Training Schedule - learn a programming language - in Autumn 2011 or 2012$ is atomic and % and @ are molecular - PerlFrom fish, loaves and apples to money, plastic cards and BACS (Perl references explained)Perl - making best use of the flexibility, but also using good coding standardsDoes a for loop evaluate its end condition once, or on every iteration?Tables as Objects in Lua - a gentle introduction to data driven programmingParallel but not really parallel. Moving game characters. Coroutines in Lua. The difference between lists and strings - TclRodwell Trail, Weymouth