[Image of Linux]
Linux's Witness Ministry
The Personal Web Pages of Chris X. Edwards

ex-p2html.pl

--------------------------
#!/usr/bin/perl
#p2html.pl

opendir SD , ".";
@files = readdir SD;

foreach $fi (@files){

if ($fi=~m/.pl$/){

print "TEST --------------------------------\n";
print "TEST ",$fi, " is a Perl file.\n";

#dots are string concatenation, the > is for output mode
$F= ">./" . $fi . ".html";
print "TEST F=",$F,"\n";
#since no filename is given, it is in the scalar of the same name ($F)
open F;

print F <<top_chunk;
<html><head><title>Chris X. Edwards - Perl Examples</title></head>

<body bgcolor="#000000" text="#FFFFFF" link="00FFFF" vlink="A020F0" alink="FF0000">

<table width=100% ><tr valign=top>

<td width=130>
<img src="./only5kbytes.jpg" width=127 height=150 alt="[Image of Linux]">
</td>

<td>
<h6 align=right>Linux's Witness Ministry<br>
The Personal Web Pages of Chris X. Edwards</h6>
top_chunk

#cxe- Special line to set the custom title
print F "<h1 align=left>",$fi,"</h1>";

print F <<mid_chunk;
</td>

</tr></table>

<img alt="--------------------------" src="./only60bytes.gif" height="3" width="100%">
<br> 
<pre>
mid_chunk

#cxe- Actually import the literal program here
#cxe- this works, but doesn't catch bad chars!!
#print F `cat $fi`;

open FI, "<".$fi;
while (<FI>) {
s/&/&amp;/g;
s/</&lt;/g;
s/>/&gt;/g;
print F;
}
close FI;

print F <<bot_chunk;
</pre>
<br>
<img alt="--------------------------" src="./only60bytes.gif" height="3" width="100%">

<table width=100%>

<tr><td align=center><a href="./menu.html">Return to Program Examples</a></td></tr>


<tr><td align=center>This page was created with only free, open-source, publicly licensed software.<br>
This page was designed to be viewed with any browser on any system.</td></tr>

<tr><td align=center><address>Chris X. Edwards ~ January 2003 </address>
</td></tr>

</table>

</body>
</html>
bot_chunk

close F;
}
}

--------------------------
Return to Program Examples
This page was created with only free, open-source, publicly licensed software.
This page was designed to be viewed with any browser on any system.
Chris X. Edwards ~ January 2003