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 09:28:31)
Associated topics are indexed under
H107 - String Handling in PHP [2629] Curly braces within double quoted strings in PHP - (2010-02-09)
[2238] Handling nasty characters - Perl, PHP, Python, Tcl, Lua - (2009-06-14)
[2165] Making Regular Expressions easy to read and maintain - (2009-05-10)
[2046] Finding variations on a surname - (2009-02-17)
[1799] Regular Expressions in PHP - (2008-09-16)
[1613] Regular expression for 6 digits OR 25 digits - (2008-04-16)
[1603] Do not SHOUT and do not whisper - (2008-04-06)
[1533] Short and sweet and sticky - PHP form input - (2008-02-06)
[1372] A taster PHP expression ... - (2007-09-30)
[1336] Ignore case in Regular Expression - (2007-09-08)
[1195] Regular Express Primer - (2007-05-20)
[1058] PHP Regular expression to extrtact link and text - (2007-01-31)
[1008] Date conversion - PHP - (2006-12-26)
[728] Looking ahead and behind in a Regular Expression - (2006-05-22)
[716] Evaluating arithmetic expressions in configuration files - (2006-05-10)
[642] How similar are two words - (2006-03-11)
[608] Don't expose your regular expressions - (2006-02-15)
[589] Robust PHP user inputs - (2006-02-03)
[574] PHP - dividing a string up into pieces - (2006-01-23)
[560] The fencepost problem - (2006-01-10)
[558] Converting between acres and hectares - (2006-01-08)
[463] Splitting the difference - (2005-10-13)
[422] PHP Magic Quotes - (2005-08-22)
[337] the array returned by preg_match_all - (2005-06-06)
[54] PHP and natural sorting - (2004-09-19)
[31] Here documents - (2004-08-28)
H999 - Additional PHP Material [2215] If nothing, make it nothing. - (2009-06-02)
[2073] Extra PHP Examples - (2009-03-09)
[1623] PHP Techniques - a workshop - (2008-04-26)
[1519] Flipping images on your web page - (2008-01-26)
[1505] Script to present commonly used images - PHP - (2008-01-13)
[1485] Copyright and theft of images, bandwidth and members. - (2007-12-26)
[1451] More PHP sample and demonstration programs - (2007-12-01)
[1391] Ordnance Survey Grid Reference to Latitude / Longitude - (2007-10-14)
[1390] Converting from postal address to latitude / longitude - (2007-10-13)
[1389] Controlling and labelling Google maps via PHP - (2007-10-13)
[1270] PHP Standalone - keyboard to screen - (2007-07-18)
[1194] Drawing hands on a clock face - PHP - (2007-05-19)
[1104] Drawing dynamic graphs in PHP - (2007-03-09)
[1053] Sorting people by name in PHP - (2007-01-26)
[1020] Parallel processing in PHP - (2007-01-03)
[1010] Dates, times, clickable diarys in PHP - (2006-12-28)
[937] Display an image from a MySQL database in a web page via PHP - (2006-11-22)
[917] Syntax checking in PHP - (2006-11-07)
[839] Reporting on the 10 largest files or 10 top scores - (2006-08-20)
[822] PHP - a team member leaves - (2006-08-04)
[806] Check your user is human. Have him retype a word in a graphic - (2006-07-17)
[789] Hot answers in PHP - (2006-07-02)
[687] Presentation, Business and Persistence layers in Perl and PHP - (2006-04-17)
[665] PHP Image viewing application - (2006-04-01)
[603] PHP - setting sort order with an associative array - (2006-02-13)
[563] Merging pictures using PHP and GD - (2006-01-13)
[483] Double Dollars in PHP - (2005-11-02)
[468] Stand alone PHP programs - (2005-10-18)
[372] Time calculation in PHP - (2005-07-08)
[322] More maps - (2005-05-23)
[320] Ordnance Survey - using a 'Get a map' - (2005-05-22)
[239] What and why for the epoch - (2005-03-08)
P210 - Perl - Topicalization and Special Variables [1922] Flurinci knows Raby Lae PHP and Jeve - (2008-12-04)
[1860] Seven new intermediate Perl examples - (2008-10-30)
[1829] Dont bother to write a Perl program - (2008-10-10)
[1728] A short Perl example - (2008-07-30)
[1705] Environment variables in Perl / use Env - (2008-07-11)
[1704] Finding operating system settings in Perl - (2008-07-10)
[1508] How not to write Perl? - (2008-01-15)
[1444] Using English can slow you right down! - (2007-11-25)
[1289] Pure Perl - (2007-08-03)
[1232] Bathtub example - (2007-06-14)
[1221] Bathtubs and pecking birds - (2007-06-07)
[1136] Buffering output - why it is done and issues raised in Tcl, Perl, Python and PHP - (2007-04-06)
[969] Perl - $_ and @_ - (2006-12-07)
[639] Progress bars and other dynamic reports - (2006-03-09)
P221 - Perl on the Web [2551] Perl and the Common Gateway Interface - out of fashion but still very useful? - (2009-12-26)
[1198] From Web to Web 2 - (2007-05-21)
[975] Answering ALL the delegate's Perl questions - (2006-12-09)
[662] An unhelpful error message from Apache httpd - (2006-03-30)
[641] Simple but rugged form handling demo - (2006-03-10)
[590] Danny and Donna are getting married - (2006-02-03)
[433] FTP - how to make the right transfers - (2005-09-01)
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