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))
Perl functions such as chop change their input parameters

Typically, functions / named blocks of code take a series of operands / parameters as inputs, and return a result which is saved into another variable - here's an example in Perl:

  $size = length($persname);

Incoming value - read from $persname
Action defined in - length
Outgoing value - saved into $size

However - I have said typically, as in some languages it's possible for a function to amend the input values as well. Take a look at this Perl line:

  $boots = chop($feet);

$boots gets set to the final character of the incoming string in $feet which is modified by the removal of that character. So:

Incoming in $feet: Hello[cr]
Outgoing in $boots: [cr]
Outgoing in $feet: Hello

Once you're aware of this action from the chop function, it works very well for you ... but it comes as a bit of a surprise the first time you see it!

Complete source example (and sample output) [here]. We cover this subject (and of course a lot more!) on our Perl Programming course.

(written 2012-01-10, updated 2012-01-14)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P209 - Subroutines in Perl
  [96] Variable Scope - (2004-10-22)
  [308] Call by name v call by value - (2005-05-11)
  [357] Where do Perl modules load from - (2005-06-24)
  [531] Packages in packages in Perl - (2005-12-16)
  [588] Changing @INC - where Perl loads its modules - (2006-02-02)
  [775] Do not duplicate your code - (2006-06-23)
  [969] Perl - $_ and @_ - (2006-12-07)
  [1163] A better alternative to cutting and pasting code - (2007-04-26)
  [1202] Returning multiple values from a function (Perl, PHP, Python) - (2007-05-24)
  [1782] Calling procs in Tcl and how it compares to Perl - (2008-09-02)
  [1784] Global - Tcl, PHP, Python - (2008-09-03)
  [1826] Perl - Subs, Chop v Chomp, => v , - (2008-10-08)
  [1850] Daisy the Cow and a Pint of Ginger Beer - (2008-10-21)
  [1860] Seven new intermediate Perl examples - (2008-10-30)
  [1921] Romeo and Julie - (2008-12-04)
  [2069] Efficient calls to subs in Perl - avoid duplication, gain speed - (2009-03-07)
  [2550] Do not copy and paste code - there are much better ways - (2009-12-26)
  [2833] Fresh Perl Teaching Examples - part 2 of 3 - (2010-06-27)
  [2929] Passing a variable number of parameters in to a function / method - (2010-08-20)
  [3066] Separating groups of variables into namespaces - (2010-11-24)
  [3833] Learning to use existing classes in Perl - (2012-08-10)

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)
  [1946] Variable Types in Perl - (2008-12-15)
  [2442] Variable storage - Perl, Tcl and Python compared - (2009-10-08)
  [2832] Are you learning Perl? Some more examples for you! - (2010-06-27)
  [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)
  [3398] Perl - making best use of the flexibility, but also using good coding standards - (2011-08-19)
  [3542] What order are operations performed in, in a Perl expression? - (2011-12-07)
  [3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
  [4324] Learning to program - variables and constants - (2014-11-22)


Back to
New in Java 7 - and why we are not running public Java 7 courses
Previous and next
or
Horse's mouth home
Forward to
Multiple buttons calling the same proc in wish (tcl/tk)
Some other Articles
A busy start to 2012
How to do multidimensional arrays (or rather lists and hashes) in Perl
Tcl - apparently odd behaviour of string trimleft
Multiple buttons calling the same proc in wish (tcl/tk)
Perl functions such as chop change their input parameters
New in Java 7 - and why we are not running public Java 7 courses
Adding Expect on top of Tcl - what is it and where can I get a training course to learn about it?
Comparing loop commands in Tcl
Trapping errors in Tcl - the safety net that catch provides
Images of the new year in Melksham
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/3574_Per ... eters.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb