note
mkmcconn
<p>[CHRYSt], you'll find many posts here directing you to [cpan://File::Find]. It's very easy to use (although there
are some peculiarities that may put you off at first, much
clearer code can be produced with it than you'll find
in my sample below)</p>
<p>Download the snippet below, and see if it does pretty much what you want. I can hardly imagine it taking 3 hours,
even on a very large and deep directory.</p>
<p>If it works for you, take a closer look at the module and the examples in [http://www.perldoc.com/perl5.005_03/lib/File/Find.html#SYNOPSIS|the documentation] (<i>perldoc File::Find</i>).</p>
<code>
#!/usr/bin/perl -w
use strict;
use File::Find;
print "Content-Type: text/html\n\n";
print "<html><body><h1>Web Server Directory Listing</h1>";
my $dir_count = 0;
my $file_count= 0;
find(\&{ sub {
if (-d $_){ # File::Find puts us in the directory.
# We can stat, copy or rename
# without needing to know
# which directory we are in.
print $dir_count > 0?"</ul>\n":"";
print "<h3>Directory ",
++$dir_count,
": <a href='$File::Find::dir/$_'>$_</a></h3>\n<ul> \n" ;
# $File::Find::dir
# is the current directory
}
else{
print "<li>",
++$file_count,
" <a href='$File::Find::name'>$_</a></li>\n" ;
# $File::Find::name
# is the full path of the current file.
}
}
}, '/Intranet/html');
print "\n</ul>";
print "</body></html>";
</code>
<br />
[mkmcconn]
<br />
<b>fiddled</b> with text after posting.</p>
137318
137318