1 |
#!/usr/local/bin/perl -w |
2 |
use strict; |
3 |
|
4 |
# This is a short example that basically does the same |
5 |
# thing as the default file system access method |
6 |
|
7 |
# This will index only one directory (the current directory) |
8 |
# See the more advanced example DirTree.pl in the swish-e prog-bin directory. |
9 |
|
10 |
|
11 |
my $dir = '.'; |
12 |
opendir D, $dir or die $!; |
13 |
while ( $_ = readdir D ) { |
14 |
next unless /\.htm$/; |
15 |
my ( $size, $mtime ) = (stat "$dir/$_" )[7,9]; |
16 |
open FH, "$dir/$_" or die "$! on $dir/$_"; |
17 |
|
18 |
print <<EOF; |
19 |
Content-Length: $size |
20 |
Last-Mtime: $mtime |
21 |
Path-Name: $dir/$_ |
22 |
|
23 |
EOF |
24 |
print <FH>; |
25 |
} |
26 |
|
27 |
|
28 |
|
29 |
|