line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Trifid::Utils; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$Crypt::Trifid::Utils::VERSION = '0.11'; |
4
|
|
|
|
|
|
|
$Crypt::Trifid::Utils::AUTHORITY = 'cpan:MANWAR'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Crypt::Trifid::Utils - Helper package for Crypt::Trifid. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.11 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
59
|
use 5.006; |
|
4
|
|
|
|
|
13
|
|
17
|
4
|
|
|
4
|
|
18
|
use strict; use warnings; |
|
4
|
|
|
4
|
|
6
|
|
|
4
|
|
|
|
|
65
|
|
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
77
|
|
18
|
4
|
|
|
4
|
|
16
|
use Data::Dumper; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
159
|
|
19
|
4
|
|
|
4
|
|
1527
|
use parent 'Exporter'; |
|
4
|
|
|
|
|
1079
|
|
|
4
|
|
|
|
|
18
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @EXPORT_OK = qw(generate_chart); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
B |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub generate_chart { |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
3
|
0
|
11
|
my $chars = _generate_charset(); |
32
|
3
|
|
|
|
|
6
|
my $chart = {}; |
33
|
3
|
|
|
|
|
10
|
foreach my $i (0..2) { |
34
|
9
|
|
|
|
|
14
|
foreach my $j (0..2) { |
35
|
27
|
|
|
|
|
37
|
foreach my $k (0..2) { |
36
|
81
|
|
|
|
|
181
|
$chart->{$chars->[$i]->[$j]->[$k]} = sprintf("%d%d%d", $i+1, $j+1, $k+1); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
33
|
return $chart; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
# |
46
|
|
|
|
|
|
|
# PRIVATE METHODS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _generate_charset { |
49
|
|
|
|
|
|
|
|
50
|
3
|
|
|
3
|
|
20
|
my @chars = ('A' .. 'Z', ' '); |
51
|
3
|
|
|
|
|
5
|
my $chars = []; |
52
|
3
|
|
|
|
|
6
|
my $seen = {}; |
53
|
3
|
|
|
|
|
12
|
foreach my $i (0..2) { |
54
|
9
|
|
|
|
|
16
|
foreach my $j (0..2) { |
55
|
27
|
|
|
|
|
34
|
foreach my $k (0..2) { |
56
|
81
|
|
|
|
|
88
|
my $char = ''; |
57
|
81
|
|
|
|
|
118
|
while ($char eq '') { |
58
|
329
|
|
|
|
|
418
|
$char = _get_char(@chars); |
59
|
329
|
100
|
|
|
|
528
|
if (exists $seen->{$char}) { |
60
|
248
|
|
|
|
|
357
|
$char = ''; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else { |
63
|
81
|
|
|
|
|
163
|
$seen->{$char} = 1; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
81
|
|
|
|
|
137
|
$chars->[$i]->[$j]->[$k] = $char; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
3
|
|
|
|
|
20
|
return $chars; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
329
|
|
|
329
|
|
1187
|
sub _get_char { my (@chars) = @_; return $chars[ rand @chars ]; } |
|
329
|
|
|
|
|
917
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Mohammad S Anwar, C<< >> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 REPOSITORY |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
L |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 BUGS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Please report any bugs/feature requests to C or |
87
|
|
|
|
|
|
|
through the web interface at L. |
88
|
|
|
|
|
|
|
I will be notified & then you'll automatically be notified of progress on your bug |
89
|
|
|
|
|
|
|
as I make changes. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SUPPORT |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
perldoc Crypt::Trifid::Utils |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
You can also look for information at: |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * CPAN Ratings |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * Search CPAN |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Copyright (C) 2014 - 2017 Mohammad S Anwar. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This program is free software; you can redistribute it and / or modify it under |
124
|
|
|
|
|
|
|
the terms of the the Artistic License (2.0). You may obtain a copy of the full |
125
|
|
|
|
|
|
|
license at: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified Versions is |
130
|
|
|
|
|
|
|
governed by this Artistic License.By using, modifying or distributing the Package, |
131
|
|
|
|
|
|
|
you accept this license. Do not use, modify, or distribute the Package, if you do |
132
|
|
|
|
|
|
|
not accept this license. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made by someone |
135
|
|
|
|
|
|
|
other than you,you are nevertheless required to ensure that your Modified Version |
136
|
|
|
|
|
|
|
complies with the requirements of this license. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service mark, |
139
|
|
|
|
|
|
|
tradename, or logo of the Copyright Holder. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge patent license |
142
|
|
|
|
|
|
|
to make, have made, use, offer to sell, sell, import and otherwise transfer the |
143
|
|
|
|
|
|
|
Package with respect to any patent claims licensable by the Copyright Holder that |
144
|
|
|
|
|
|
|
are necessarily infringed by the Package. If you institute patent litigation |
145
|
|
|
|
|
|
|
(including a cross-claim or counterclaim) against any party alleging that the |
146
|
|
|
|
|
|
|
Package constitutes direct or contributory patent infringement,then this Artistic |
147
|
|
|
|
|
|
|
License to you shall terminate on the date that such litigation is filed. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND |
150
|
|
|
|
|
|
|
CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED |
151
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR |
152
|
|
|
|
|
|
|
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS |
153
|
|
|
|
|
|
|
REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, |
154
|
|
|
|
|
|
|
INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE |
155
|
|
|
|
|
|
|
OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
1; # End of Crypt::Trifid::Utils |