"Just give me the data". Where there's a requirement to take data from another program into a Perl or PHP script, it's often easier simply to take the data in a format that it's offered / exported from that other program and use code in Perl or PHP to make appropriate use of that data. The alternative of getting the data supplier to do all sorts of manipulation is, frankly, more trouble than it's worth.
Lisa has passed me a data flow - a dump of all the Melksham retail businesses - from the map she's been working on and is being shown at the West Wilts Show today. It's good, it contains what I need, but it's formatted with the map in mind rather than with the data meaning ("how it should look" rather than "what it means"). Now I could ask for it in XML ;-) ... of I could use Perl or PHP and their powerful text handlers. I have chose to do the latter.
Here is the main "what's this line" decision code - in PHP:
if (ereg("^ ",$record)) { # MAIN HEADER
elseif (count($els) == 1) { # SUB HEAD
elseif (count($els) == 2 and ereg("^[1-9]",$els[1])) { # OUT OF TOWN on map
elseif (count($els) == 2) { # OUT OF TOWN LOCATION not on map
elseif (count($els) == 3) { # IN TOWN LOCATION
else { # ERROR
and here is the
formatted list of Melksham retailers I have produced from it. The source code is
here. The next stage is going to be to produce listings by area ... as I have the data in my PHP code now, that will be easy. And I know that I need to put a good look and feel onto it!
You can download the map from
here.
(written 2009-07-25 07:22:13)
Associated topics are indexed under
H104 - PHP - Control Statements [1825] Question Mark - Colon operator (Perl and PHP) - (2008-10-08)
[1696] Saying NOT in Perl, PHP, Python, Lua ... - (2008-07-04)
[1477] Decisions - small ones, or big ones? - (2007-12-18)
[1220] for loop - how it works (Perl, PHP, Java, C, etc) - (2007-06-06)
[1199] Testing for one of a list of values. - (2007-05-22)
[1191] Smart English Output - via PHP and Perl ? : operator - (2007-05-18)
[962] Breaking a loop - Ruby and other languages - (2006-12-03)
[863] Double and Triple equals operator in PHP - (2006-09-12)
[657] The ternary operator in Python - (2006-03-25)
[421] Don't repeat code - use loops or functions - (2005-08-21)
[406] Assignment, equality and identity in PHP - (2005-08-08)
[353] Wimbledon Neck - (2005-06-20)
[340] Code and code maintainance efficiency - (2005-06-08)
Some other Articles
A new place in picturesBreakfast in MexicoMelksham to Mexico for the weekHot Tap at West Wilts ShowExtracting real data from an exported file in PHP or PerlTurning potential customers awaySee us at the West Wilts ShowMistaken identity?What does x on a linux directory mean?How much space does my directory take - Linux