Our web site update has been progessing well over the last couple of weeks - you'll probably have notices that most of the pages changed a fortnight ago and the remaining pages are now switching over one or two at a time ... they're typically the more awkward ones!
We've been providing on site training for years .. and quoting on line through a Perl script that is probably the longest standing piece of code on the site. Some of the regular expressions to tell a UK postcode apart from a Canadian one, and to check distances and ferry requirements .... well - let me just say I did NOT fancy updating them to include them within a PHP page.
Solution? Use the "legacy" code and call it in from the new PHP front end. I've amended the Perl slightly to recognise when it's called from the PHP ... additional lines in the Perl to collect incoming parameters:
if ($ARGV[0] eq "php") {
$buffer = join(" ",@ARGV[1..$#ARGV]);
$form{"method"} = "INTERNAL";
} else {
if ($ENV{"REQUEST_METHOD"} eq "POST") {
read(STDIN,$buffer,$ENV{"CONTENT_LENGTH"});
$form{"method"} = "POST";
} else {
$buffer = $ENV{QUERY_STRING};
$form{"method"} = "GET";
}
}
and to return the table as a URL response rather than as HTML:
if ($form{"method"} eq "INTERNAL") {
foreach $key (keys %form) {
# next if ($key eq "price");
$kv = $form{$key};
$kv =~ s/([^a-zA-Z0-9 ])/sprintf("%%%02x",ord($1))/eg;
$kv =~ s/ /+/g;
push @retst,"$key=$kv";
}
$ret = join("&",@retst);
print "$ret\n";
} else {
print "Content-type: text/html\n\n";
print $html;
}
and I've used PHP's shell_exec to run the old Perl code:
$poc = shell_exec("cd $_SERVER[DOCUMENT_ROOT]/../cgi-bin/net; ./excalc.pl php where=$_REQUEST[where]");
$parms = explode("&",$poc);
Try the new quote system (written 2005-11-12, updated 2006-06-05)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P221 - Perl on the Web [433] FTP - how to make the right transfers - (2005-09-01)
[590] Danny and Donna are getting married - (2006-02-03)
[641] Simple but rugged form handling demo - (2006-03-10)
[662] An unhelpful error message from Apache httpd - (2006-03-30)
[687] Presentation, Business and Persistence layers in Perl and PHP - (2006-04-17)
[975] Answering ALL the delegate's Perl questions - (2006-12-09)
[1198] From Web to Web 2 - (2007-05-21)
[2551] Perl and the Common Gateway Interface - out of fashion but still very useful? - (2009-12-26)
[3875] Using CGI and Perl to put a simple application online. Sometimes still the best way. - (2012-09-30)
P210 - Perl - Topicalization and Special Variables [639] Progress bars and other dynamic reports - (2006-03-09)
[969] Perl - $_ and @_ - (2006-12-07)
[1136] Buffering output - why it is done and issues raised in Tcl, Perl, Python and PHP - (2007-04-06)
[1221] Bathtubs and pecking birds - (2007-06-07)
[1232] Bathtub example - (2007-06-14)
[1289] Pure Perl - (2007-08-03)
[1444] Using English can slow you right down! - (2007-11-25)
[1508] How not to write Perl? - (2008-01-15)
[1704] Finding operating system settings in Perl - (2008-07-10)
[1705] Environment variables in Perl / use Env - (2008-07-11)
[1728] A short Perl example - (2008-07-30)
[1829] Dont bother to write a Perl program - (2008-10-10)
[1860] Seven new intermediate Perl examples - (2008-10-30)
[1922] Flurinci knows Raby Lae PHP and Jeve - (2008-12-04)
[2833] Fresh Perl Teaching Examples - part 2 of 3 - (2010-06-27)
[2876] Different perl examples - some corners I rarely explore - (2010-07-18)
[2972] Some more advanced Perl examples from a recent course - (2010-09-27)
[3449] Apache Internal Dummy Connection - what is it and what should I do with it? - (2011-09-19)
[4301] Perl - still a very effective language indeed for extracting and reporting - (2014-09-20)
[4395] Preparing data through a little bit of Perl - (2015-01-15)
[4682] One line scripts - Awk, Perl and Ruby - (2016-05-20)
[4700] Obfurscated code - it might work, but is it maintainable? - (2016-07-02)
H999 - Additional PHP Material [54] PHP and natural sorting - (2004-09-19)
[239] What and why for the epoch - (2005-03-08)
[320] Ordnance Survey - using a 'Get a map' - (2005-05-22)
[322] More maps - (2005-05-23)
[337] the array returned by preg_match_all - (2005-06-06)
[372] Time calculation in PHP - (2005-07-08)
[468] Stand alone PHP programs - (2005-10-18)
[483] Double Dollars in PHP - (2005-11-02)
[563] Merging pictures using PHP and GD - (2006-01-13)
[603] PHP - setting sort order with an associative array - (2006-02-13)
[665] PHP Image viewing application - (2006-04-01)
[789] Hot answers in PHP - (2006-07-02)
[806] Check your user is human. Have him retype a word in a graphic - (2006-07-17)
[822] PHP - a team member leaves - (2006-08-04)
[839] Reporting on the 10 largest files or 10 top scores - (2006-08-20)
[917] Syntax checking in PHP - (2006-11-07)
[937] Display an image from a MySQL database in a web page via PHP - (2006-11-22)
[1010] Dates, times, clickable diarys in PHP - (2006-12-28)
[1020] Parallel processing in PHP - (2007-01-03)
[1053] Sorting people by name in PHP - (2007-01-26)
[1104] Drawing dynamic graphs in PHP - (2007-03-09)
[1194] Drawing hands on a clock face - PHP - (2007-05-19)
[1270] PHP Standalone - keyboard to screen - (2007-07-18)
[1389] Controlling and labelling Google maps via PHP - (2007-10-13)
[1390] Converting from postal address to latitude / longitude - (2007-10-13)
[1391] Ordnance Survey Grid Reference to Latitude / Longitude - (2007-10-14)
[1451] More PHP sample and demonstration programs - (2007-12-01)
[1485] Copyright and theft of images, bandwidth and members. - (2007-12-26)
[1505] Script to present commonly used images - PHP - (2008-01-13)
[1519] Flipping images on your web page - (2008-01-26)
[1623] PHP Techniques - a workshop - (2008-04-26)
[2073] Extra PHP Examples - (2009-03-09)
[2215] If nothing, make it nothing. - (2009-06-02)
[2684] Exception handling in PHP - (2010-03-18)
[3118] Arrays of arrays - or 2D arrays. How to program tables. - (2011-01-02)
[3210] Catchable fatal error in PHP ... How to catch, and alternative solutions such as JSON - (2011-03-22)
[4655] Image indexer / thumbnail display scripts in PHP - (2016-02-25)
H107 - String Handling in PHP [31] Here documents - (2004-08-28)
[422] PHP Magic Quotes - (2005-08-22)
[463] Splitting the difference - (2005-10-13)
[558] Converting between acres and hectares - (2006-01-08)
[560] The fencepost problem - (2006-01-10)
[574] PHP - dividing a string up into pieces - (2006-01-23)
[589] Robust PHP user inputs - (2006-02-03)
[608] Don't expose your regular expressions - (2006-02-15)
[642] How similar are two words - (2006-03-11)
[716] Evaluating arithmetic expressions in configuration files - (2006-05-10)
[728] Looking ahead and behind in a Regular Expression - (2006-05-22)
[1008] Date conversion - PHP - (2006-12-26)
[1058] PHP Regular expression to extrtact link and text - (2007-01-31)
[1195] Regular Express Primer - (2007-05-20)
[1336] Ignore case in Regular Expression - (2007-09-08)
[1372] A taster PHP expression ... - (2007-09-30)
[1533] Short and sweet and sticky - PHP form input - (2008-02-06)
[1603] Do not SHOUT and do not whisper - (2008-04-06)
[1613] Regular expression for 6 digits OR 25 digits - (2008-04-16)
[1799] Regular Expressions in PHP - (2008-09-16)
[2046] Finding variations on a surname - (2009-02-17)
[2165] Making Regular Expressions easy to read and maintain - (2009-05-10)
[2238] Handling nasty characters - Perl, PHP, Python, Tcl, Lua - (2009-06-14)
[2629] Curly braces within double quoted strings in PHP - (2010-02-09)
[3020] Handling (expanding) tabs in PHP - (2010-10-29)
[3424] Divide 10000 by 17. Do you get 588.235294117647, 588.24 or 588? - Ruby and PHP - (2011-09-08)
[3515] PHP - moving from ereg to preg for regular expressions - (2011-11-11)
[3516] Regular Expression modifiers in PHP - summary table - (2011-11-12)
[3534] Learning to program in PHP - Regular Expression and Associative Array examples - (2011-12-01)
[3788] Getting more than a yes / no answer from a regular expression pattern match - (2012-06-30)
[3789] More than just matching with a regular expression in PHP - (2012-06-30)
[3790] Solution looking for a problem? Lookahead and Lookbehind - (2012-06-30)
[4071] Setting up strings in PHP - (2013-04-27)
[4072] Splitting the difference with PHP - (2013-04-27)
Some other Articles
I have a river to crossPython printfMore spam - a success storyMySQL - a score of things to rememberRunning a Perl script within a PHP pageNew Navigation Aid - Launch of My WellhoBeing atypical is typicalA new way to get lostWhich MySQL server am I using?Looking for railway groups and users - Swindon, Salisbury, Southampton