#!/usr/bin/perl-w;use strict 'vars';
my ($file1,$file2,$file3,$file4);
my (%anrede,%titel,%name,%personname);
my ($a,$b,$c);
#open a file, and read to hash, suppose each line is a term of name/calling
$file1="c:\\Perl\\Copy\\anrede.txt"; #herr,frau,etc...
$file2="c:\\Perl\\Copy\\titel.txt"; #..
$file3="c:\\Perl\\Copy\\name.txt"; #..
$file4="c:\\Perl\\Copy\\zeitung.txt"; #
open(FH,'<',$file1) or die $!;
while(my $a=<FH>){
chomp($a);
$anrede{$a}=1;
}
open(FHA,'<',$file2) or die $!;
while(my $b=<FHA>){
chomp($b);
$titel{$b}=1;
}
open(FHN,'<',$file3) or die $!;
while(my $c=<FHN>){
chomp($c);
$name{$c}=1;
}
###########open the zeitung.txt
open(ZT,'<',$file4) or die $!;
while (my $line=<ZT>){
chomp($line);
$line=~s/\W+/ /g; #loeschen alle "nicht-wort" zeichen
my @line=split(/\s+/,$line); #split line to word
foreach my $word(@line){
if ($word=~/^[A-Z]\w+/){
if (exists $anrede{$word}){
$a=$word;
}
elsif (exists $titel{$word})
{
$b=$word;
}
elsif (exists $name{$word})
{
$c=$word;
}
else
{
}
}
}
my $name=$a." ".$b." ".$c; #full name
print"$name";
$personname{$c}++; #put the name to %personname
$a=""; #clear $a.$b.$c for the next name
$b="";
$c="";
}