|
Revision 221, 1.6 kB
(checked in by whmoseley, 8 years ago)
|
Replace the user.config file with a collection of
simple examples.
|
- Property svn:eol-style set to
native
- Property svn:executable set to
*
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
use strict; |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
use lib '../prog-bin'; |
|---|
| 13 |
|
|---|
| 14 |
use File::Find; |
|---|
| 15 |
use pdf2xml; |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
use constant DEBUG => 0; |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
my $dir = shift || '.'; |
|---|
| 27 |
|
|---|
| 28 |
find( |
|---|
| 29 |
{ |
|---|
| 30 |
wanted => \&wanted, |
|---|
| 31 |
no_chdir => 1, |
|---|
| 32 |
}, |
|---|
| 33 |
$dir, |
|---|
| 34 |
); |
|---|
| 35 |
|
|---|
| 36 |
sub wanted { |
|---|
| 37 |
return if -d; |
|---|
| 38 |
|
|---|
| 39 |
if ( /\.pdf$/ ) { |
|---|
| 40 |
print STDERR "Indexing pdf $File::Find::name\n" if DEBUG; |
|---|
| 41 |
print ${ pdf2xml( $File::Find::name ) }; |
|---|
| 42 |
|
|---|
| 43 |
} elsif ( /\.config$/ ) { |
|---|
| 44 |
print STDERR "Indexing $File::Find::name\n" if DEBUG; |
|---|
| 45 |
print ${ get_content( $File::Find::name ) }; |
|---|
| 46 |
|
|---|
| 47 |
} else { |
|---|
| 48 |
print STDERR "Skipping $File::Find::name\n" if DEBUG; |
|---|
| 49 |
} |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
sub get_content { |
|---|
| 54 |
my $path = shift; |
|---|
| 55 |
|
|---|
| 56 |
my ( $size, $mtime ) = (stat $path )[7,9]; |
|---|
| 57 |
open FH, $path or die "$path: $!"; |
|---|
| 58 |
|
|---|
| 59 |
my $content = <<EOF; |
|---|
| 60 |
Content-Length: $size |
|---|
| 61 |
Last-Mtime: $mtime |
|---|
| 62 |
Path-Name: $path |
|---|
| 63 |
|
|---|
| 64 |
EOF |
|---|
| 65 |
local $/ = undef; |
|---|
| 66 |
$content .= <FH>; |
|---|
| 67 |
return \$content; |
|---|
| 68 |
} |
|---|