diff options
Diffstat (limited to 'Aufgabe3/skript3.pl')
| -rw-r--r-- | Aufgabe3/skript3.pl | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Aufgabe3/skript3.pl b/Aufgabe3/skript3.pl new file mode 100644 index 0000000..68ed536 --- /dev/null +++ b/Aufgabe3/skript3.pl @@ -0,0 +1,74 @@ +#!/usr/bin/env perl +#=============================================================================== +# +# FILE: skript3.pl +# +# USAGE: ./skript3.pl +# +# DESCRIPTION: +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Stefan Suhren (su), suhren.stefan@fh-swf.de +# ORGANIZATION: FH Südwestfalen, Iserlohn +# VERSION: 1.0 +# CREATED: 06.11.2015 00:27:04 +# REVISION: --- +#=============================================================================== + +use strict; +use warnings; +use utf8; + +# enforce utf-8 mode +binmode (STDIN, ":encoding(UTF-8)"); +binmode (STDOUT, ":encoding(UTF-8)"); +binmode (STDERR, ":encoding(UTF-8)"); +use open ":encoding(UTF-8)"; + +my $ERGEBNIS_file_name = "loesung.dat"; + +# pipe commands: +my $INPUTPIPE_command = './quadrat|'; +my $OUTPUTPIPE_command = " | sort | uniq | column > $ERGEBNIS_file_name"; + +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"; + +my $german_file_name = 'german.lst'; # input file name + +open my $germanFile, '<', $german_file_name + or die "$0 : failed to open input file '$german_file_name' : $!\n"; + +my %german; + +while (my $line = <$germanFile>) +{ + $german{uc $line} = 0; +} + +close $germanFile + or warn "$0 : failed to close input file '$german_file_name' : $!\n"; + +my @loesung; + +while (my $line = <$INPUTPIPE>) +{ + if (exists $german{uc $line}) + { + push @loesung, uc $line; + } +} + +print $OUTPUTPIPE @loesung; + +close $OUTPUTPIPE + or warn "$0 : failed to close pipe > $OUTPUTPIPE_command < : $!\n"; +close $INPUTPIPE + or warn "$0 : failed to close pipe > $INPUTPIPE_command < : $!\n"; + |
