File: file.pl

package info (click to toggle)
swish-e 2.4.7-7.1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 8,188 kB
  • sloc: ansic: 51,640; sh: 8,889; perl: 3,019; makefile: 591; xml: 9
file content (29 lines) | stat: -rwxr-xr-x 583 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl -w
use strict;

# This is a short example that basically does the same
# thing as the default file system access method

# This will index only one directory (the current directory)
# See the more advanced example DirTree.pl in the swish-e prog-bin directory.


my $dir = '.';
opendir D, $dir or die $!;
while ( $_ = readdir D   ) {
    next unless /\.htm$/;
    my ( $size, $mtime )  = (stat "$dir/$_" )[7,9];
    open FH, "$dir/$_" or die "$! on $dir/$_";

    print <<EOF;
Content-Length: $size
Last-Mtime: $mtime
Path-Name: $dir/$_

EOF
    print <FH>;
}