Re: A perl program to translate HTML to Perl?

Walter Ian Kaye (walter@natural-innovations.com)
Thu, 16 Apr 1998 08:51:19 -0700


At 10:17p -0700 04/15/98, JohnBeaman wrote:
>> Richard Sharpe wrote:
>> has anyone built a Perl program that can take HTML and convert it to a Perl
>> program that uses CGI.pm to produce the same HTML?
>>
>> We are building pages using CyberStudio, but many of these pages need to be
>> translated to Perl as CGI scripts. Hand translating them is a pain.
>
>Why not just have the Perl program "send" the html"???
>No need to "translate" at all.  Save the html as a
>".txt" file and:
>
> open(FILE,"$htmlfile.txt");
> @STUFF=<FILE>;
> close(FILE);
> print @STUFF;
> exit;

No need to rename the html file either, actually. ;)
(Perl wouldn't care if you named it Dippity-Do...)

While you're at it, you could turn parts of the html into "variables"
for substitution when perl re-emits the code. Something like:
<TITLE>`TTL</TITLE> and then do a y/`TTL/$thistitle/ on the contents
before spitting it back out. You get the idea. (I picked the ` because
it seems to be the least-used character.)