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 under
H109 - PHP - Input / Output [3424] Divide 10000 by 17. Do you get 588.235294117647, 588.24 or 588? - Ruby and PHP - (2011-09-08)
[3159] Returning multiple values from a function call in various languages - a comparison - (2011-02-06)
[3029] PHP data sources - other web servers, large data flows, and the client (browser) - (2010-11-04)
[2964] An introduction to file handling in programs - buffering, standard in and out, and file handles - (2010-09-21)
[1780] Server overloading - turns out to be feof in PHP - (2008-09-01)
[1442] Reading a file multiple times - file pointers - (2007-11-23)
[1113] File and URL reading in PHP - (2007-03-20)
[1096] Sample script - FTP to get a file from within PHP - (2007-03-01)
[1094] PHP fread - truncated data - (2007-02-27)
[997] Most recent file in a directory - PHP - (2006-12-18)
[709] Handling huge data files in PHP - (2006-05-04)
[653] Easy feed! - (2006-03-21)
[616] printf - a flawed but useful function - (2006-02-22)
P207 - Perl - File Handling [3548] Dark mornings, dog update, and Python and Lua courses before Christmas - (2011-12-10)
[3326] Finding your big files in Perl - design considerations beyond the course environment - (2011-06-14)
[2833] Fresh Perl Teaching Examples - part 2 of 3 - (2010-06-27)
[2821] Chancellor George Osborne inspires Perl Program - (2010-06-22)
[2818] File open and read in Perl - modernisation - (2010-06-19)
[2405] But I am reading from a file - no need to prompt (Perl) - (2009-09-14)
[2233] Transforming data in Perl using lists of lists and hashes of hashes - (2009-06-12)
[1861] Reactive (dynamic) formatting in Perl - (2008-10-31)
[1860] Seven new intermediate Perl examples - (2008-10-30)
[1841] Formatting with a leading + / Lua and Perl - (2008-10-15)
[1709] There is more that one way - Perl - (2008-07-14)
[1467] stdout v stderr (Tcl, Perl, Shell) - (2007-12-10)
[1416] Good, steady, simple example - Perl file handling - (2007-10-30)
[1312] Some one line Perl tips and techniques - (2007-08-21)
[867] Being sure to be positive in Perl - (2006-09-15)
[702] Iterators - expressions tha change each time you call them - (2006-04-27)
[618] Perl - its up to YOU to check your file opened - (2006-02-23)
[255] STDIN, STDOUT, STDERR and DATA - Perl file handles - (2005-03-23)
[12] How many people in a room? - (2004-08-12)
Y110 - Python - File Handling [3558] Python or Lua - which should I use / learn? - (2011-12-21)
[3465] How can I do an FTP transfer in Python? - (2011-10-05)
[3442] A demonstration of how many Python facilities work together - (2011-09-16)
[3083] Python - fresh examples from recent courses - (2010-12-11)
[2870] Old prices - what would the equivalent price have been in 1966? - (2010-07-14)
[2282] Checking robots.txt from Python - (2009-07-12)
[2011] Conversion of OSI grid references to Eastings and Northings - (2009-01-28)
[183] The elegance of Python - (2005-01-19)
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