blob: c6741a860cecf13f1f221ac5189cd284d7fdc0d5 (
plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/usr/bin/env perl
#===============================================================================
#
# FILE: BuchstabenPipe.pl
#
# USAGE: ./BuchstabenPipe.pl
#
# DESCRIPTION: Wörter aus zwei datein vergleichen
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Martin Talarczyk (MT), talarczyk.martin@fh-swf.de
# ORGANIZATION: FH Südwestfalen, Iserlohn
# Matrikel-Nr.: 10036162
# VERSION: 1.0
# CREATED: 28.10.2015 09:27:56
# REVISION: ---
#===============================================================================
use strict;
use warnings;
use utf8;
binmode (STDIN, ":encoding(UTF-8)");
binmode (STDOUT, ":encoding(UTF-8)");
binmode (STDERR, ":encoding(UTF-8)");
use open ":encoding(UTF-8)";
#-------------------------------------------------------------------------------
# Variabelen Deklarasion
#-------------------------------------------------------------------------------
my $outputFile = "output.dat";
my $wolistfp_file_name = 'german.lst'; # input file name
my %german;
#Programm ausführen und auf stdin schreiben
my $INPUTPIPE_command = './quadrat|';
# Eingabe Sortieren | ohene Doppelte | in schön > schreibe in
my $OUTPUTPIPE_command = " | sort | uniq | column > $outputFile";
open my $INPUTPIPE, $INPUTPIPE_command or die "$0 : failed to open pipe > $INPUTPIPE_command < : $!\n";
open my $OUTPUTPIPE, $OUTPUTPIPE_command or die "$0 : failed to open pipe > $OUTPUTPIPE_command < : $!\n";
#====================================================================================
# Wörter list lesen german.lst
#====================================================================================
print "Wörter liste lesen...\n";
open my $wolistfp, '<', $wolistfp_file_name
or die "$0 : failed to open input file '$wolistfp_file_name' : $!\n";
while (my $word = <$wolistfp>)
{
$word = uc $word;
$german {$word} = $word;
}
close $wolistfp
or warn "$0 : failed to close input file '$wolistfp_file_name' : $!\n";
#====================================================================================
# lese von quadrat aus über pipe, Schreibe in ausgabe datei, ersetzt quadrat.dat ar
#====================================================================================
print "Auswertung...\n";
while (<$INPUTPIPE>)
{
# wenn Wort in $germen existirt Schreibe in Ausgabe datei
print $OUTPUTPIPE $_ if exists $german {$_};
}
close $OUTPUTPIPE or warn "$0 : failed to close pipe > $OUTPUTPIPE_command < : $!\n";
close $INPUTPIPE or warn "$0 : failed to close pipe > $INPUTPIPE_command < : $!\n";
print "Anzahl der Wörter: " . `wc -w $outputFile | cut -f1 -d' '`;
|