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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#!/usr/bin/env perl
#===============================================================================
#
# FILE: skript4-3.pl
#
# USAGE: ./skript4-3.pl
#
# DESCRIPTION: Erstellt eine Hash mit wörte die nach Buchstaben sorirt ist
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Martin Talarczyk (MT), martin@talarczyk.de
# ORGANIZATION: Fachhochschule Südwestfalen, Iserlohn
# VERSION: 1.0
# CREATED: 07.11.2015 11:33:21
# REVISION: ---
#===============================================================================
use strict;
use warnings;
use utf8;
use Data::Dumper;
binmode (STDIN, ":encoding(UTF-8)");
binmode (STDOUT, ":encoding(UTF-8)");
binmode (STDERR, ":encoding(UTF-8)");
use open ":encoding(UTF-8)";
#===============================================================================
# Variabelen Deklarasion
#===============================================================================
# Hash mit einem String als Key und einem feld als Wert.
my %wordlist;
my $wordkey;
print "Skript startet...\n";
my $wordfp_file_name = 'GERMAN9.LST'; # input file name
print "\n";
$wordkey = make_key("blablabla");
print "\n";
open my $wordfp, '<', $wordfp_file_name
or die "$0 : failed to open input file '$wordfp_file_name' : $!\n";
while ( my $line = <$wordfp> ) {
chomp $line;
$wordkey = make_key($line);
chomp $wordkey;
push @{ $wordlist{ $wordkey } }, $line;
}
#print Dumper \%wordlist;
#exit;
close $wordfp
or warn "$0 : failed to close input file '$wordfp_file_name' : $!\n";
print "Hash wurde erstellt...\n";
print "geben sie ein Word ein welches nur aus Bustabenbesteht\n";
my $inputKey = <>;
chomp $inputKey;
my $inputKeyuc = make_key($inputKey);
chomp $inputKeyuc;
while($inputKeyuc !~ /^[A-Z]{9}$/i)
{
print "Die eingabe war Falscht bitte erneut eingebe\n";
$inputKey = <>;
chomp $inputKey;
print $inputKey . "\n";
my $inputKeyuc = make_key($inputKey);
print $inputKeyuc . "\n";
chomp $inputKeyuc;
}
if( exists $wordlist{ $inputKeyuc } )
{
printf( "Eingabe: %s\nFolgende Woerter treffen zu:\n", $inputKey );
printf( "%s", "@{ $wordlist{ $inputKeyuc } }" );
}
else
{
printf( "Dieses Wort existiert nicht.\n%s", $inputKey );
}
#=== FUNCTION ================================================================
# NAME: make_key
# PURPOSE:
# PARAMETERS: Eine Sklar String der behandelt wird.
# RETURNS: Feld mit string
# DESCRIPTION: Ein Sortiren String.
# THROWS: no exceptions
# COMMENTS: none
# SEE ALSO: n/a
#===============================================================================
sub make_key {
my ( $word ) = @_;
defined $word or die "Es wurde keien String übergeben.\n";
my @temparry = split //, uc $word;
@temparry = sort @temparry;
my $erg = join "" , @temparry;
return $erg;
} ## --- end sub make_key
|