Google Gruppi non supporta più i nuovi post o le nuove iscrizioni Usenet. I contenuti storici continuano a essere visibili.

hacking up

6 visualizzazioni
Passa al primo messaggio da leggere

Kirk Is

da leggere,
18 gen 2002, 18:49:1618/01/02
a
I just did some software hacks in some of the truest senses of the word.

Hack #1: (Legacy Hack)
It all started with the code I was given. To mail the results of a
template, some programmer was told to call a tcl script that parses an
.htcl template and emails the result. So *their* hack was to fake up a
POST request by forming the key/values part of the equivalent URL, opening
the script in a pipe, and printing the &general=mush to the file handle.

Hack #2
Well, that tcl script the perl was calling was breaking. Badly. And I
didn't want to figure it out...it was so evil it made this legacy perl
script look good. I also didn't want to figure out the gruesome code that
put all those key=value pairs together. Since it was clear that this
programmer wasn't doing anything special to escape the URL except changing
spaces to pluses, I undid that, split the whole string on &, and split
each key/value pair on = and put 'em into an associative array...much
easier to work with.

Hack #3
So now I needed to parse the same .htcl script the tcl code used to.
This script had associative array references $ar(like this), which
were replaced with the form data values for those "like this" keys.
Now I load the template into a variable, use a reg ex to change
$ar(this)
into
$formdata{"this"}
then I add a
return qq|
to the front and a
|;
to the back of the variable, and the result of eval()ing that is a
properly parsed template.

This system is slated for replacement soon, and I think these hacks should
hold 'til then.


--
QUOTEBLOG: http://kisrael.com SKEPTIC MORTALITY: http://kisrael.com/mortal
"The Wonder Twins had the right idea. I defy you to think of any crisis
situation that would not be vastly improved by the presence of a gorilla
with a bucket of water." --Maraud

0 nuovi messaggi