#!/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>) { chomp $line; $german{uc $line} = 0; } close $germanFile or warn "$0 : failed to close input file '$german_file_name' : $!\n"; while (my $line = <$INPUTPIPE>) { chomp $line; if (exists $german{uc $line}) { printf $OUTPUTPIPE "%s\n", uc $line; } } close $OUTPUTPIPE or warn "$0 : failed to close pipe > $OUTPUTPIPE_command < : $!\n"; close $INPUTPIPE or warn "$0 : failed to close pipe > $INPUTPIPE_command < : $!\n";