Rather contrary to current trends, we've just started taking regular deliveries of milk (+ bread + eggs) at our training centre from the local milkman. As we grow busier, it's more effective to have someone deliver to us as part of his round rather than having to make a special trip out. And our "mint on the pillow" approach to training means we really want to provide real milk rather than powder for the real coffee.
Monday's delivery - ace. Fine. AOK. A little bit of a stocking up order for the start of (another) busy week. For this morning, we asked for 5 pints of semi-skimmed milk. Sure - we got them. And a pint of Channel Island. And a pint of full fat. And bread. And eggs ...
At first thought - had our instructions been ignored? No - it turns out that our Milkman took our instruction as a relative path (i.e. changes from what we had on Monday) rather than an absolute path. Perhaps we should have written C:\ or / on the front of the order?
Why is this relevant to Horse's Mouth? Because so often people write their programs using a relative path when they would be better using an absolute, or vice versa, and it's a reminder worth making. Just this morning, I answered a question on Opentalk where my writer was having problems, I suspect, because of a changed current directory and a relative path.
When we look at
file handling in Perl (or take a
second or even
a third look) - or when we get involved with
file handling in PHP or
Python or our other languages, we always try to stress careful file name selection in order to ensure that the user's script works correctly no matter what their current directory. I think I'll start telling my "milkman story" to help people appreciate the importance.
(written 2004-11-10, updated 2006-06-05)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
Y110 - Python - File Handling [183] The elegance of Python - (2005-01-19)
[1442] Reading a file multiple times - file pointers - (2007-11-23)
[2011] Conversion of OSI grid references to Eastings and Northings - (2009-01-28)
[2282] Checking robots.txt from Python - (2009-07-12)
[2870] Old prices - what would the equivalent price have been in 1966? - (2010-07-14)
[3083] Python - fresh examples from recent courses - (2010-12-11)
[3442] A demonstration of how many Python facilities work together - (2011-09-16)
[3465] How can I do an FTP transfer in Python? - (2011-10-05)
[3558] Python or Lua - which should I use / learn? - (2011-12-21)
[3764] Shell, Awk, Perl of Python? - (2012-06-14)
[4438] Loving programming in Python - and ready to teach YOU how - (2015-02-22)
[4451] Running an operating system command from your Python program - the new way with the subprocess module - (2015-03-06)
[4593] Command line parameter handling in Python via the argparse module - (2015-12-08)
[4663] Easy data to object mapping (csv and Python) - (2016-03-24)
[4708] Scons - a build system in Python - building hello world - (2016-10-29)
[4717] with in Python - examples of use, and of defining your own context - (2016-11-02)
P207 - Perl - File Handling [12] How many people in a room? - (2004-08-12)
[255] STDIN, STDOUT, STDERR and DATA - Perl file handles - (2005-03-23)
[616] printf - a flawed but useful function - (2006-02-22)
[618] Perl - its up to YOU to check your file opened - (2006-02-23)
[702] Iterators - expressions tha change each time you call them - (2006-04-27)
[867] Being sure to be positive in Perl - (2006-09-15)
[1312] Some one line Perl tips and techniques - (2007-08-21)
[1416] Good, steady, simple example - Perl file handling - (2007-10-30)
[1467] stdout v stderr (Tcl, Perl, Shell) - (2007-12-10)
[1709] There is more that one way - Perl - (2008-07-14)
[1841] Formatting with a leading + / Lua and Perl - (2008-10-15)
[1860] Seven new intermediate Perl examples - (2008-10-30)
[1861] Reactive (dynamic) formatting in Perl - (2008-10-31)
[2233] Transforming data in Perl using lists of lists and hashes of hashes - (2009-06-12)
[2405] But I am reading from a file - no need to prompt (Perl) - (2009-09-14)
[2818] File open and read in Perl - modernisation - (2010-06-19)
[2821] Chancellor George Osborne inspires Perl Program - (2010-06-22)
[2833] Fresh Perl Teaching Examples - part 2 of 3 - (2010-06-27)
[3326] Finding your big files in Perl - design considerations beyond the course environment - (2011-06-14)
[3548] Dark mornings, dog update, and Python and Lua courses before Christmas - (2011-12-10)
[3830] Traversing a directory in Perl - (2012-08-08)
[3839] Spraying data from one incoming to series of outgoing files in Perl - (2012-08-15)
H109 - PHP - Input / Output [653] Easy feed! - (2006-03-21)
[709] Handling huge data files in PHP - (2006-05-04)
[997] Most recent file in a directory - PHP - (2006-12-18)
[1094] PHP fread - truncated data - (2007-02-27)
[1096] Sample script - FTP to get a file from within PHP - (2007-03-01)
[1113] File and URL reading in PHP - (2007-03-20)
[1780] Server overloading - turns out to be feof in PHP - (2008-09-01)
[2964] An introduction to file handling in programs - buffering, standard in and out, and file handles - (2010-09-21)
[3029] PHP data sources - other web servers, large data flows, and the client (browser) - (2010-11-04)
[3159] Returning multiple values from a function call in various languages - a comparison - (2011-02-06)
[3424] Divide 10000 by 17. Do you get 588.235294117647, 588.24 or 588? - Ruby and PHP - (2011-09-08)
[4483] Moving from mysql to mysqli - simple worked example - (2015-05-03)
Some other Articles
History around youA case of caseThe next generation of programmerExpiration dates or times on web pagesRelative or absolute milkmanA Parallel for Perl 6Avoid the wheel being re-invented by using Perl modulesTraining notes available under Open Distribution licenseFriday, busy week!URLs - a service and not a hurdle