--- find3.pl 2002/01/31 16:54:32 1.1.1.1 +++ find3.pl 2002/06/19 10:58:59 1.5 @@ -1,7 +1,13 @@ #!/usr/bin/perl -w +# indexer, Dobrica Pavlinusic 2002-01-28 +# options: -q quiet +# -d debug +# -v verbose + use strict; use DBI; +use Getopt::Std; my $sadrzaj=0; my $nr=0; @@ -13,6 +19,11 @@ my $nn_dir="."; # dir u kojem su wget-ani fileovi +my %opts; +getopts("vqd", \%opts); + +my $brojeva=0; +my $zakona=0; #-------------------------------------------------------------------- @@ -92,7 +103,7 @@ $tmp_word = $word.$add; } if ($tmp_word =~ m/$regexp/ix) { -# print "$word -> $tmp_word\t-$sub, +$add, regexp: $regexp\n"; + print "$word -> $tmp_word\t-$sub, +$add, regexp: $regexp\n" if ($opts{d}); push @out,lc($tmp_word); } } @@ -114,12 +125,16 @@ my @files = grep { /^CijeliBrojS/ && -f "$nn_dir/$_" } readdir(DIR); closedir(DIR); +my $sth=$dbh->prepare("insert into nn (br,god,nr,aname,title,title_czs) values (?,?,?,?,?,?)") || die $dbh->errstr(); + + foreach my $file (@files) { open(IN,$file) || die "can't open $file: $!"; if ($file=~m/god=(\d+)\&br=(\d+)/) { ($br,$god) = ($2,$1); - print "$file -- $2 -- $1\n"; + print "$file -- $2 -- $1\n" if (! $opts{q}); + $brojeva++; } while() { @@ -127,34 +142,46 @@ s/\015//g; # kill cr tr/šðžèæŠÐŽÈÆ/¹ð¾èæ©Ð®ÈÆ/; # 1250 -> iso8859-2 - $sadrzaj++ if (m,