Priprava na semafor, zatim obsahuje ZAVAZNY DEADLOCK
[mirrors/Programs.git] / perl / index / index.pl
CommitLineData
21c4e167
H
1#!/usr/bin/env perl
2use strict;
3use warnings;
4use File::Find;
5use URI::Escape;
6
7my $index_dir = './index';
8my $docus_dir = './docs';
9
10unlink <$index_dir/*>;
11find({ wanted => \&index_file, no_chdir=>1 }, $docus_dir);
12
13sub index_file() {
14 print $File::Find::name."\n";
15 open(my $fh, '<', $File::Find::name) or die $!;
16 while(<$fh>) {
17 $_ =~ s/\<[^\<]+\>//g; #strip tags
18 $_ = lc($_);
19
20 foreach(split(/[\s]/,$_)) {
21 $_ =~ /^\s+|\s+$/g; #trim
22 if($_ eq '') { next; }
23
24 print "$_\n";
25 $_ = uri_escape($_);
26 $_ = $index_dir.'/'.$_;
27
28 open(my $ifh, '>>', $_) or die $!;
29 print $ifh "$File::Find::name\n";
30 close($ifh);
31 }
32 }
33 close($fh);
34}
This page took 0.194248 seconds and 4 git commands to generate.