-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmorse_de
More file actions
65 lines (62 loc) · 800 Bytes
/
morse_de
File metadata and controls
65 lines (62 loc) · 800 Bytes
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
#!/usr/bin/perl -w
my $alpha = '.';
my $beta = '-';
my %table =
(
ab => 'a',
baa => 'b',
baba => 'c',
baa => 'd',
a => 'e',
aaba => 'f',
bba => 'g'
aaaa => 'h'
aa => 'i',
abbb => 'j',
bab => 'k',
abaa => 'l',
bb => 'm',
ba => 'n',
bbb => 'o',
abba => 'p',
bbab => 'q',
aba => 'r',
aaa => 's',
b => 't',
aab => 'u',
aaab => 'v',
abb => 'w',
baab => 'x',
babb => 'y',
bbaa => 'z',
bbbbb => 0,
abbbb => 1,
aabbb => 2,
aaabb => 3,
aaaab => 4,
aaaaa => 5,
baaaa => 6,
bbaaa => 7,
bbbaa => 8,
bbbba => 9,
ababab => '.',
bbaabb => ',',
aabbaa => '?'
);
while(<>)
{
tr/$alpha/a/;
tr/$beta/b/;
my @words = split(/\s+//, $_);
foreach my $word (@words)
{
if(my $trans = $table{$word})
{
print $trans . ' ';
}
else
{
print "$_ ";
}
}
}