<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
	<channel>
		<language>en_GB</language>
		<title>source2html</title>
		<link>http://tobyinkster.co.uk/article/source2html/</link>
		<description>
&lt;p&gt;I needed to print out a directory full of small scripts. This Perl script will go through the current directory and create a pretty HTML page of all the files in that directory. That HTML page can then be fed to a browser for printing.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;perl&quot;&gt;#!/usr/bin/perl

$cd = `pwd`; chomp $cd;
$ls = `ls -1 $cd`;
@ls = split(/\n/,$ls);

print &quot;&amp;lt;title&amp;gt;Directory Listing $cd&amp;lt;/title&amp;gt;\n&quot;;
print &quot;&amp;lt;h1&amp;gt;Directory Listing $cd&amp;lt;/h1&amp;gt;\n&quot;;

$ll = `ls -l '$cd'`;
chomp $ll;
print &quot;&amp;lt;pre style='padding:1em'&amp;gt;&amp;lt;b&amp;gt;$ll&amp;lt;/b&amp;gt;&amp;lt;/pre&amp;gt;\n\n&quot;;

foreach $f (@ls) {

  if (!(-d $f)) {

    $l = `ls -l '$f'`; chomp $l;
    print &quot;&amp;lt;div style='border:2px solid black;padding:1em;'&amp;gt;\n&quot;;
    print &quot;&amp;lt;h2 style='margin:0;padding:0;'&amp;gt;$f&amp;lt;/h2&amp;gt;\n&quot;;
    print &quot;&amp;lt;pre&amp;gt;&amp;lt;b&amp;gt;$l&amp;lt;/b&amp;gt;&amp;lt;/pre&amp;gt;\n&quot;;
    print &quot;&amp;lt;/div&amp;gt;\n&quot;;

    $t = `cat '$f'`;
    $t =~ s/&amp;amp;/&amp;amp;amp;/g;
    $t =~ s/&amp;lt;/&amp;amp;lt;/g;
    $t =~ s/&amp;gt;/&amp;amp;gt;/g;

    print &quot;&amp;lt;pre style='padding:1em'&amp;gt;$t&amp;lt;/pre&amp;gt;\n\n&quot;;

  }

}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This software is distributed under the terms of the &lt;a href=&quot;http://www.gnu.org/copyleft/gpl.html&quot;&gt;GNU GPL&lt;/a&gt;.&lt;/p&gt;

</description>
	</channel>
</rss>
